[thelist] PHP file upload problem

Melissa Phelps Firestone liss at frameshift.com
Thu Dec 4 15:20:08 CST 2003


I've run into a problem with a PHP script that was working perfectly until
today but has suddenly descended into madness. It's a simple form that
allows the user to upload two files.

Here's the code that I'm using to evaluate the uploads and put them into
variables to use later:

...snip...

if ($_FILES) { 
    extract($_FILES['first'], EXTR_PREFIX_ALL, 'first');
    if(is_uploaded_file($first_tmp_name)) {
        if (!move_uploaded_file($first_tmp_name, $location.$first_name)) {
            echo "Upload failed.<br />Debugging information:<br />";
            print_r($_FILES)."<br />\n";
        }
    } 

    extract($_FILES['second'], EXTR_PREFIX_ALL, 'second');
    if(is_uploaded_file($second_tmp_name)) {
        if (!move_uploaded_file($second_tmp_name, $location.$second_name)) {
            echo "Upload failed.<br />Debugging information:<br />";
            print_r($_FILES)."<br />\n";
        }
    } 
}

...snip...

This was all working perfectly yesterday. Sometime today, the $_FILES
autovariable seems to have reversed itself - if nothing is uploaded using
either file field, $_FILES contains both first and second arrays (both empty
of data). For any file that is uploaded, that array is empty. (If I send a
file using the second file field, then $_FILES contains an empty "first"
array, but no "second" array exists.) If I try to upload two files, then
$_FILES does not exist at all.

Any suggestions for what else I can check or what could be wrong would be
vastly appreciated.

Thanks,
--Liss



More information about the thelist mailing list