Title: $_FILES empty
Last modified: August 18, 2016

---

# $_FILES empty

 *  Resolved [blobaya](https://wordpress.org/support/users/blobaya/)
 * (@blobaya)
 * [20 years ago](https://wordpress.org/support/topic/_files-empty/)
 * hi
 * first, sorry for my english …
    I tried to make an upload form for a personnal
   manager plugin (on the dmin interface). Every time i do an “upload”, the $_FILES
   variable is empty. My form and my script seems to be ok (chown and chmod is OK
   too). In another hand, i’ve no problem with the default worpdress upload.
 * is everyone have the same problem ?
 * >require_once(‘admin.php’);
    >include(‘admin-header.php’); >require_once(‘../
   wp-content/plugins/wp-picture/wp-picture.php’); >(..) >if (is_uploaded_file($
   _FILES[‘picture’][‘tmp_name’])) > do >else > my form
 * thanks for help me,
    blobaya

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

 *  [forceagainstsomething](https://wordpress.org/support/users/forceagainstsomething/)
 * (@forceagainstsomething)
 * [20 years ago](https://wordpress.org/support/topic/_files-empty/#post-364420)
 * blobaya,
    Can you point us to the upload form? Or copy/paste the HTML here so
   we can check that out.
 *  Personally I don’t use the is_uploaded_file() function. I just do something 
   like this:
 * if ($_FILES) {
 * }
 *  And that’s enough. The $_FILES array won’t exists if a file wasn’t uploaded 
   via a form.
 *  Are you adding `enctype="multipart/form-data"` to your opening form tag? Are
   you using the POST method? If you simply add something like this:
 * echo $_FILES[‘picture’][‘tmp_name’];
 *  Does it show anything?
 * – Sean
 *  Thread Starter [blobaya](https://wordpress.org/support/users/blobaya/)
 * (@blobaya)
 * [20 years ago](https://wordpress.org/support/topic/_files-empty/#post-364439)
 * my upload form:
    <form enctype=”multipart/form-data” action=”wp-admin/wp-picture-
   admin.php” method=”post”> Album <select name=”album”><?php foreach ($albums as
   $album) { echo ‘<option value=”‘.$album->album_id.’,,,’.$album->album_path.'”
   > ‘.htmlentities($album->album_name); }?></select> Picture <input type=”file”
   name=”picture” /> <input type=”submit” name=”pictupload” value=”Upload” /> </
   form>
 * my $_FILES[‘picture’][‘tmp_name’] is empty all the time. I tested the same code
   without the include header wordpress, and it’s working. I think about a reset
   globals variables on the core of wordpress but i’m not sure.
 * For testing $_FILE[] I did :
    >echo $_FILES[‘picture’][‘tmp_name’]; //empty but
   on the first line of the script ! >require_once(‘admin.php’); echo $_FILES[‘picture’][‘
   tmp_name’]; //empty >include(‘admin-header.php’); echo $_FILES[‘picture’][‘tmp_name’];//
   empty >require_once(‘../wp-content/plugins/wp-picture/wp-picture.php’);
 * thanks,
 * blobaya
 *  [forceagainstsomething](https://wordpress.org/support/users/forceagainstsomething/)
 * (@forceagainstsomething)
 * [20 years ago](https://wordpress.org/support/topic/_files-empty/#post-364466)
 * blobya,
    I don’t know. You may want to try hooking into WP’s `init` event, like
   this:
 * add_action(‘init’, ‘myfunction’);
    function myfunction() { if ($_FILES) { // 
   Something here } }
 *  Thread Starter [blobaya](https://wordpress.org/support/users/blobaya/)
 * (@blobaya)
 * [20 years ago](https://wordpress.org/support/topic/_files-empty/#post-364582)
 * I make another way to make my upload picture: ftp and a select generating thumb
   picture in my admin menu.
 * thanks for help
 * blobaya
 *  [davidchait](https://wordpress.org/support/users/davidchait/)
 * (@davidchait)
 * [20 years ago](https://wordpress.org/support/topic/_files-empty/#post-364586)
 * in the first line of wp-picture-admin.php, do something like:
    `print_r($_FILES);`
 * If that’s empty, you have other PHP or Apache issues… 😉
 *  [Appletalk](https://wordpress.org/support/users/appletalk/)
 * (@appletalk)
 * [20 years ago](https://wordpress.org/support/topic/_files-empty/#post-364587)
 * Remember that in WordPress you have the handy printr() function (notice there’s
   no _ before r) that automaticall wraps the output between <pre> and </pre>

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

The topic ‘$_FILES empty’ is closed to new replies.

 * 6 replies
 * 4 participants
 * Last reply from: [Appletalk](https://wordpress.org/support/users/appletalk/)
 * Last activity: [20 years ago](https://wordpress.org/support/topic/_files-empty/#post-364587)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
