...

View Full Version : Need Little Help Working File Upload Script



neusight
08-03-2012, 05:41 PM
Hi all. I would like to fist say Hi as i am brand new to this site. I have a code that works great. It is an upload form that will let the user upload three files through three separate browse upload lines. Only problem with the code that I currently use is that if the user does not upload three files I get this error:

Warning: copy() [function.copy]: Filename cannot be empty in /home/dedikate/public_html/www.file-warehouse.com/multiple_upload_ac.php on line 19

Warning: copy() [function.copy]: Filename cannot be empty in /home/dedikate/public_html/www.file-warehouse.com/multiple_upload_ac.php on line 20


Here is my code:


<?php //set where you want to store files
//in this example we keep file in folder upload //$HTTP_POST_FILES['ufile']['name']; = upload file name
//for example upload file name cartoon.gif . $path will be upload/cartoon.gif
$path1= "upload/".$HTTP_POST_FILES['ufile']['name'][0];
$path2= "upload/".$HTTP_POST_FILES['ufile']['name'][1];
$path3= "upload/".$HTTP_POST_FILES['ufile']['name'][2];
//copy file to where you want to store file
copy($HTTP_POST_FILES['ufile']['tmp_name'][0], $path1);
copy($HTTP_POST_FILES['ufile']['tmp_name'][1], $path2);
copy($HTTP_POST_FILES['ufile']['tmp_name'][2], $path3);
//$HTTP_POST_FILES['ufile']['name'] = file name
//$HTTP_POST_FILES['ufile']['size'] = file size
//$HTTP_POST_FILES['ufile']['type'] = type of file
?>



I got this code from http://www.phpeasystep.com/phptu/2.html

DrDOS
08-03-2012, 06:20 PM
That's a very clumsy script. There are a couple of multi-upload scripts in the snippet section, I wrote one of them, just rewrote a single upload script to handle multi uploads.

neusight
08-03-2012, 08:24 PM
That's a very clumsy script. There are a couple of multi-upload scripts in the snippet section, I wrote one of them, just rewrote a single upload script to handle multi uploads.


I looked through your code and tried it out. It seems it's only for uploading images.

DrDOS
08-03-2012, 10:23 PM
I looked through your code and tried it out. It seems it's only for uploading images.

You just change it to whatever you want to upload. You need to get the correct mime type for your files. It's just a general purpose upload script, it just happens that images are one of the most popular items to upload.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum