Click to See Complete Forum and Search --> : Mulitple file uplaod
Pino
Jun 16th, 2005, 10:43 AM
How easy is it?
Say i wanted to uplaod 10 files at a time how do i got about doing it?
ALL
Jun 16th, 2005, 12:03 PM
check these links out:
Sample:
http://www.raditha.com/php/upload.php
Source:
http://sourceforge.net/projects/megaupload/
visualAd
Jun 17th, 2005, 01:40 AM
Its actually quite easy you give each file the same name and append square brakets to it. This will make it an array in PHP:
<p>File 1: <input name="files[]" type="file" /></p>
<p>File 2: <input name="files[]" type="file" /></p>
<p>File 3: <input name="files[]" type="file" /></p>
The file array can then be accessed by means of the following:
$_FILES['files']['name'][0]
$_FILES['files']['name'][1]
Have a look here for an example: http://uk.php.net/manual/en/features.file-upload.multiple.php
bind
Jun 21st, 2005, 07:31 AM
here is a 3 page code-set to do as many uploads as you wish .. i got it somewhere a while ago and use it daily .. i dont remember who to give credit to for it ... sorry.
customize them as per your functionality needs and aesthetic formatting.
uploadForm1.php will ask you how many uplaods you want to do ... simply enter an integer between 1 and 99 (this can be changed if you need more than 99 by altering the uploadNeed maxlength variable which is 2 charactors by default, but your server might time you out on many uploads or a few with very large file sizes.)
uploadForm2.php processes the input from uploadNeed from uploadForm1.php and displays the the requested amount of file upload/browse boxes. This is where you enter the local file path or click browse to broswe to your local file path and click on file to upload.
processFiles.php does the meaty work in uploading. When the uploads complete you will get a confirmation of success or failure in the upload process.
remember that if you are trying to overwrite a file, you cant do it without the appropriate write/delete file permissions on the server.
uploadForm1.php
<html>
<head>
<title># of Files to Upload</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<form name="form1" method="post" action="uploadForm2.php">
<p>Enter the number of files to upload (Max=99 Default=1), then click Submit.</p>
<p>
<input name="uploadNeed" type="text" id="uploadNeed" maxlength="2" value="1">
</p>
<p>
<input type="submit" name="Submit" value="Submit">
</p>
</form>
</body>
</html>
uploadForm2.php
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<form name="form1" enctype="multipart/form-data" method="post" action="processFiles.php">
<p>
<?
// start of dynamic form
$uploadNeed = $_POST['uploadNeed'];
for($x=0;$x<$uploadNeed;$x++){
?>
<input name="uploadFile<? echo $x;?>" type="file" id="uploadFile<? echo $x;?>">
</p>
<?
// end of for loop
}
?>
Click the browse button and browse to the location your file resides, and click on the file to select it for uploading.<br><br>
<p><input name="uploadNeed" type="hidden" value="<? echo $uploadNeed;?>">
<input type="submit" name="Submit" value="Submit"><br><br>
after all the files are selected, click the Submit button and wait for it to upload.
<br><br>
DO NOT click Submit more than once or it may interfere with the upload progress.
<br><br>
When the file uploading is complete, you will get a message stating success or failure.
</p>
</form>
</body>
</html>
processFiles.php
<?
$uploadNeed = $_POST['uploadNeed'];
// start for loop
for($x=0;$x<$uploadNeed;$x++){
$file_name = $_FILES['uploadFile'. $x]['name'];
// strip file_name of slashes
$file_name = stripslashes($file_name);
$file_name = str_replace("'","",$file_name);
$copy = copy($_FILES['uploadFile'. $x]['tmp_name'],$file_name);
// check if successfully copied
if($copy){
echo "$file_name | uploaded sucessfully!<br>";
}else{
echo "$file_name | could not be uploaded!<br>";
}
} // end of loop
?>
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.