Title: wp_handle_upload error:&#8221;Specified file failed upload test.&#8221;
Last modified: December 22, 2020

---

# wp_handle_upload error:”Specified file failed upload test.”

 *  [susimueller](https://wordpress.org/support/users/susimueller/)
 * (@susimueller)
 * [5 years, 5 months ago](https://wordpress.org/support/topic/wp_handle_upload-errorspecified-file-failed-upload-test/)
 * Hello,
 * I am writing a membership area and want users to be able to upload images via
   forms. I am using the Code Snippets plugin for programming the interface.
    For
   testing purposes I have created a small form and file-handling snippet with following
   code:
 * include ‘wp-admin/includes/file.php’;
 * function to_upload_this(){
 *  if(!empty($_FILES[“upload_image”][“name”])){
 *  $fileType = pathinfo($_FILES[“upload_image”][“name”],PATHINFO_EXTENSION);
    $
   allowTypes = array(‘jpg’, ‘png’, ‘jpeg’, ‘svg’); if(in_array($fileType, $allowTypes)){//
   Upload file to the server $overrides = array( ‘test_form’ => false); $file = 
   $_FILES[“upload_image”]; $upload = wp_handle_upload($file, $overrides); if ( 
   is_wp_error( $upload ) ) { // There was an error uploading the image. echo “an
   error”; print_r($upload); } else { // The image was uploaded successfully! echo“
   no error”; print_r($upload); } echo ‘Path is allowed.’;
 *  }else{
    echo ‘Sorry, only JPG, JPEG, PNG & SVG files are allowed to upload.’;}}?
   > <form method=”post” enctype=”multipart/form-data”> <input type=’file’ name=”
   upload_image”>
 *  <input type=”submit” name=”submit” value=”Submit”>
    </form> <?php
 *  return;
    }
 * add_shortcode( ‘tests’,’to_upload_this’ );
 * The website uses php 7.3.25 and wordpress 5.3.1 and Strato is the host. And when
   I display phpinfo() it states that “file_uploads” is “on”.
 * It would be really nice to get some help fixing this and if you need any further
   information please ask.

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Plugin Author [Shea Bunge](https://wordpress.org/support/users/bungeshea/)
 * (@bungeshea)
 * [5 years, 5 months ago](https://wordpress.org/support/topic/wp_handle_upload-errorspecified-file-failed-upload-test/#post-13822146)
 * Have you tried the code you have out? What is not working about it?
 *  Thread Starter [susimueller](https://wordpress.org/support/users/susimueller/)
 * (@susimueller)
 * [5 years, 5 months ago](https://wordpress.org/support/topic/wp_handle_upload-errorspecified-file-failed-upload-test/#post-13826945)
 * Well it would be nice if it worked.
    If I execute it it only states:
 * no errorArray ( [error] => Specified file failed upload test. ) Path is allowed.
 * And I can’t find the image in the wordpress media center.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘wp_handle_upload error:”Specified file failed upload test.”’ is closed
to new replies.

 * ![](https://ps.w.org/code-snippets/assets/icon.svg?rev=2148878)
 * [Code Snippets](https://wordpress.org/plugins/code-snippets/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/code-snippets/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/code-snippets/)
 * [Active Topics](https://wordpress.org/support/plugin/code-snippets/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/code-snippets/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/code-snippets/reviews/)

## Tags

 * [file upload](https://wordpress.org/support/topic-tag/file-upload/)
 * [forms](https://wordpress.org/support/topic-tag/forms/)
 * [image](https://wordpress.org/support/topic-tag/image/)

 * 2 replies
 * 2 participants
 * Last reply from: [susimueller](https://wordpress.org/support/users/susimueller/)
 * Last activity: [5 years, 5 months ago](https://wordpress.org/support/topic/wp_handle_upload-errorspecified-file-failed-upload-test/#post-13826945)
 * Status: not a support question