• Resolved blobaya

    (@blobaya)


    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)
  • 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

    (@blobaya)

    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

    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

    (@blobaya)

    I make another way to make my upload picture: ftp and a select generating thumb picture in my admin menu.

    thanks for help

    blobaya

    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… ??

    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.