Jump to content

[SOLVED] Multi-file Upload - PHP $_FILE array debug


mothermugger

Recommended Posts

Hi there. I am on a mission to create a file upload project for my friend in NY who has a real need for a slick multiple file upload interface on a Linux server.

 

I have made real progress and found a great front end using jquery.multi-file-upload.js See this link: http://www.fyneworks.com/jquery/multiple-file-upload/#

for details.

 

This slick little java thing works great! See my test bed here: http://www.crossroadsonthecoast.com/multi-uploads/choosefiles2.htm

 

but I am having trouble with the PHP part that uses the FILE ARRAY,

Here is the PHP code:

 

<?php

 

echo '<pre>';

if(count($_FILES) > 0)

{

$arrfile = pos($_FILES);

$uploadfile = $uploaddir .

 

basename($arrfile['name']);

 

if (move_uploaded_file

 

($arrfile['tmp_name'], $uploadfile))

  echo "File is valid, and

 

was successfully uploaded.\n";

}

else

echo 'No files sent. Script is

 

OK!'; //Say to Flash that script

 

exists and can receive files

 

echo 'Here is some more debugging

 

info:';

print_r($_FILES);

 

echo "</pre>";

 

?>

 

Now here is my output (error) but

 

note it shows the array contents! (this print_r($_FILES); never worked in previous trys..)

 

 

Warning:  basename() expects parameter 1 to be string, array given in /home/content/s/p/e/spencedave/html/multi-uploads/multi-uploader.php on line 13

Here is some more debugging info:Array

(

    [uploadedfile] => Array

        (

            [name] => Array

                (

                    [0] =>

                    [1] => refi-1.txt

                    [2] => bills paid.pdf

                )

 

            [type] => Array

                (

                    [0] =>

                    [1] => text/plain

                    [2] => application/pdf

                )

 

            [tmp_name] => Array

                (

                    [0] =>

                    [1] => /tmp/phpbdBpjy

                    [2] => /tmp/phpVIq3rp

                )

 

            [error] => Array

                (

                    [0] => 4

                    [1] => 0

                    [2] => 0

                )

 

            => Array

                (

                    [0] => 0

                    [1] => 228

                    [2] => 56671

                )

 

        )

 

)

 

 

I note that the [0] element has no file name - this is due to the nature

of the file upload field, as the array is built that filed is always blank so

on submit it's blank unless you type something in there yourself.

 

Any help on the debug would be great!

 

 

 

 

  • 3 weeks later...

Thanks for all the help!

 

I was able to solve the mystery and now have a very cool AJAX multi file  upload project that uses PHP.

 

Check out my demo here: http://www.ezwayweb.com/upload_multiple_files_PHP_sample_code.htm

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.