General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old August 30th, 2003, 12:24 PM
Volitics Volitics is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Location: Knoxville, Tennessee (U.S.A.)
Posts: 58 Volitics User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 m 15 sec
Reputation Power: 16
"copy()" Function Not Working With File Upload

Below is a multiple-file upload script. The form input part works ok. The variables $FileType, $FileName, $FileSize, $TempName, and $FileError work fine. But just after $FileError (which does not output an error message) the script just stops. The problem appears to be with the "copy()" function. I can simplify the script, make it just a single file upload script, use the variable $userfile for the first part of the "copy() function, and it uploads the file just fine.

The problem is when I try to make it a multiple-file upload script like the one below - then the copy function won't work.

I would appreciate if anyone could spot the problem.
PHP Code:
 $Admin[UploadNum] = "10";
if(
$FileUpload) {
for (
$Number 1$Number <= $Admin[UploadNum]; $Number++){
if (
$FileUpload) {
$FileType $_FILES["userfile"."$Number"]["type"];
$FileName $_FILES["userfile"."$Number"]["name"];
$FileSize $_FILES["userfile"."$Number"]["size"];
$TempName $_FILES["userfile"."$Number"]["tmp_name"];
$FileError $_FILES["userfile"."$Number"]["error"];
echo 
"File Type: $FileType<p>"// $FileType prints out fine.
echo "File Name: $FileName<p>\n"// $FileName prints out fine.
echo "File Size: $FileSize<p>\n"// $FileSize prints out fine.
echo "Temporary Name: $TempName<p>\n"// $TempName prints out fine.
echo "Error Message: $FileError<p>\n"// Does not output error message - appears to work fine.
// ------------ The script stops working right here ------------
if (copy ($_FILES['userfile'.'$Number']['name'], "users/".$_FILES["userfile"."$Number"]["name"]."")) {
    echo 
"Your file was successfully uploaded!<p>\n";
} else {
    echo 
"Your file could not be copied.<p>\n";
}
}
}
unlink ($userfile);
}else{
echo 
"<form action=\"$PHP_SELF\" enctype=\"multipart/form-data\" method=\"post\">\n";
for (
$Number 1$Number <= $Admin[UploadNum]; $Number++){
echo 
"<input name=\"userfile"."$Number\" type=\"file\" size=\"25\">\n";    
}
echo 
"<input name=\"FileUpload\" type=\"submit\" value=\"Upload Files\"></form>\n";



Thanks.

Volitics
__________________
Thomas Jefferson: "Democracy will work only until the political incumbents discover they can perpetuate themselves in office by taxing the industrious to bribe the indolent."

Reply With Quote
  #2  
Old August 30th, 2003, 01:06 PM
Volitics Volitics is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Location: Knoxville, Tennessee (U.S.A.)
Posts: 58 Volitics User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 m 15 sec
Reputation Power: 16
I Think That I've Got It Figured Out

I think that I may have the problem resolved. What I've done is replace the $_FILES['userfile'.'$Number']['name'] snippet at the first of the "copy" function with the variable "$TempName".

It seems to be working now.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > "copy()" Function Not Working With File Upload


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap