VB icon

Another way to Upload

Email
Submitted on: 1/1/2015 4:45:00 AM
By: Steve Oliver (from psc cd)  
Level: Beginner
User Rating: By 11 Users
Compatibility: PHP 4.0
Views: 1678
 
     Uploads up to 5 files user PHP, works perfectly on win32 servers such as IIS or Apache for windows. Demonstrates the use of copy(), functions, and switch operators.
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
				
//**************************************
// Name: Another way to Upload
// Description:Uploads up to 5 files user PHP, works perfectly on win32 servers such as IIS or Apache for windows. Demonstrates the use of copy(), functions, and switch operators.
// By: Steve Oliver (from psc cd)
//
// Inputs:$destination should be set to where you want the files uploaded to.
//**************************************

<?
function uploadProg($filename1,$filename1_name,$filename2,$filename2_name,$filename3,$filename3_name,$filename4,$filename4_name,$filename5,$filename5_name){
########Set the destination here##############
$destination="C:\\Uploads\\";
copy($filename1,$destination."/".$filename1_name);
copy($filename2,$destination."/".$filename2_name);
copy($filename3,$destination."/".$filename3_name);
copy($filename4,$destination."/".$filename4_name);
copy($filename5,$destination."/".$filename5_name);
echo "<h1>File(s) Uploaded...</h1>";
echo "<b>$filename1_name was uploaded succesfully.</b><br>";
echo "<b>$filename2_name was uploaded succesfully.</b><br>";
echo "<b>$filename3_name was uploaded succesfully.</b><br>";
echo "<b>$filename4_name was uploaded succesfully.</b><br>";
echo "<b>$filename5_name was uploaded succesfully.</b><br><br>";
echo "<a href=\"upload.php\">Click here to go back.</a>";
}
function main(){?>
<form method="post" action="upload.php" enctype="multipart/form-data">
Files to Upload:<br>
<input type="file" name="filename1" size="20" tabindex="1"><br>
<input type="file" name="filename2" size="20" tabindex="2"><br>
<input type="file" name="filename3" size="20" tabindex="3"><br>
<input type="file" name="filename4" size="20" tabindex="4"><br>
<input type="file" name="filename5" size="20" tabindex="5"><br>
<input type="hidden" name="action" value="uploadProg">
<input type="submit" value="Upload Files" tabindex="6">
</form><?}
switch ($action){
default:
main();
break;
case "uploadProg":
if ($filename1=="none") {echo("<h1>No File Selected....</h1>"); break;}
uploadProg($filename1,$filename1_name,$filename2,$filename2_name,$filename3,$filename3_name,$filename4,$filename4_name,$filename5,$filename5_name);
break;
}
?>


Other 4 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Beginner category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.