PHP $_FILES multiple file uploading problem?

A lot of suggestions here. I'll give it a go. This is based on @Pekka 's comment.

Up vote 2 down vote favorite share g+ share fb share tw.

I have a little problem with uploading multiple files in PHP , I have this html form: and this is the upload. Php : when i'm sending a file it show me this: Array ( myfile => Array ( name => Array ( 0 => Krw_Qe4QKmI. Mp3 ) type => Array ( 0 => ) tmp_name => Array ( 0 => ) error => Array ( 0 => 1 ) size => Array ( 0 => 0 ) ) ) so far so good.

The problem starts when I upgrade my form to this one : now , when I send 2 files , it show me this : Array ( ) so , what's the problem here? Thank you , Mor. Php forms file-upload upload multiple link|improve this question asked Sep 18 '11 at 18:36Mor Sela4688 76% accept rate.

You have an error in the first array you show (with the code 1). See here for what it means: php.net/manual/en/features.file-upload.e... – Pekka Sep 18 '11 at 19:27.

A lot of suggestions here. I'll give it a go. This is based on @Pekka 's comment.

I see you're testing with mp3s, which probably exceed PHP upload limit. This is because in your first example, you actually have an upload error code 1: The uploaded file exceeds the upload_max_filesize directive in php.ini.. So even your fist upload didn't work. A successful upload always has 0 as the error code.

Modify you php. Ini with upload_max_filesize = 10M (or 20M, or 300M; careful about that M - which means megabytes - as omitted, brings alot of headache. I suggest testing with smaller files, as I see you have a limit of 2M for uploading.

Further reading.

I did run this command but nothing came up , I also checked in the ini file it self it does not have such a thing – Mor Sela Sep 18 '11 at 18:59.

I would bet that you exceeded post_max_size and PHP just ignored the uploaded files. It's 8MB by default. If you try to upload one 5MB file everything will work.

If you try to upload 2 5MB files, it exceeeds 8MB and PHP ignores posted data. Try increasing the value of post_max_size in your php.ini.

I did , nothing changed. – Mor Sela Sep 18 '11 at 18:59 enable log_errors and look at your server's error_log – arnaud576875 Sep 18 '11 at 19:01 im checking now , so far I can see if I upload 2 small files it works but with bigger files it won't – Mor Sela Sep 18 '11 at 19:06 I run my code on WAMP 2 32 bit , this is what's on my ini ;;;;;;;;;;;;;;;; ; File Uploads ; ;;;;;;;;;;;;;;;; ; Whether to allow HTTP file uploads. ; php.net/file-uploads file_uploads = On ; Temporary directory for HTTP uploaded files (will use system default if not ; specified).

; php.net/upload-tmp-dir upload_tmp_dir = "c:/wamp/tmp" ; Maximum allowed size for uploaded files. ; php.net/upload-max-filesize upload_max_filesize = 2M – Mor Sela Sep 18 '11 at 19:42.

The php. Ini file must have something like this: ;;;;;;;;;;;;;;;; ; File Uploads ; ;;;;;;;;;;;;;;;; ; Whether to allow HTTP file uploads. File_uploads = On ; Temporary directory for HTTP uploaded files (will use system default if not ; specified).

;upload_tmp_dir = ; Maximum allowed size for uploaded files. Upload_max_filesize = 50M ; Maximum number of files that can be uploaded via a single request max_file_uploads = 20 Change the values of upload_max_filesize and then restart the server.

– Mor Sela Sep 18 '11 at 19:30 @Mor you need to modify your own php. Ini, it's no good downloading somebody else's – Pekka Sep 18 '11 at 19:35 that's weird, you can copy & paste the code in you php. Ini file and this is the content of the php.

Ini recommend I have php 5.2.17 – tttony Sep 18 '11 at 19:37.

The Problem is your name="myfile" attribute on your input-Element. You cant referer later in PHP to your file, if you haven't an identifier for it. The PHP-Documentation gives you the same hint: php.net/manual/en/features.file-upload.m... Multiple files can be uploaded using different name for input.

So change the name to "myfile1" and "myfile2" (or some better name ;)) should solve your problem.

Actually, you can upload multiple files having the same input name, just like OP used: name. – nevvermind Dec 11 '11 at 16:29.

To do multiple files at once, try giving an index like this: .

I had the same problem.. All my efforts were in vain, but finally I found a pretty good note at the PHP Manual. It's simple but suited me perfectly... "Multiple upload might not work if you use a table for displaying your form inputs when element is inside the element. In this case only the first file will be uploaded.

Put the element outside the element to get it to work. " Follow this link for the full note, there is a function to rearrange the multiple upload file array in a easy-to-use manner. php.net/manual/en/features.file-upload.m....

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions