Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 08-03-2012, 05:41 PM   PM User | #1
neusight
New to the CF scene

 
Join Date: Aug 2012
Posts: 7
Thanks: 4
Thanked 0 Times in 0 Posts
neusight is an unknown quantity at this point
Need Little Help Working File Upload Script

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 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
neusight is offline   Reply With Quote
Old 08-03-2012, 06:20 PM   PM User | #2
DrDOS
Senior Coder

 
Join Date: Sep 2010
Posts: 1,226
Thanks: 11
Thanked 156 Times in 156 Posts
DrDOS is infamous around these parts
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.
DrDOS is online now   Reply With Quote
Users who have thanked DrDOS for this post:
neusight (08-06-2012)
Old 08-03-2012, 08:24 PM   PM User | #3
neusight
New to the CF scene

 
Join Date: Aug 2012
Posts: 7
Thanks: 4
Thanked 0 Times in 0 Posts
neusight is an unknown quantity at this point
Quote:
Originally Posted by DrDOS View Post
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.

Last edited by neusight; 08-03-2012 at 08:32 PM..
neusight is offline   Reply With Quote
Old 08-03-2012, 10:23 PM   PM User | #4
DrDOS
Senior Coder

 
Join Date: Sep 2010
Posts: 1,226
Thanks: 11
Thanked 156 Times in 156 Posts
DrDOS is infamous around these parts
Quote:
Originally Posted by neusight View Post
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.
DrDOS is online now   Reply With Quote
Users who have thanked DrDOS for this post:
neusight (08-06-2012)
Reply

Bookmarks

Tags
php, upload

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:33 AM.


Advertisement
Log in to turn off these ads.