note 40678 deleted from features.file-upload.multiple by betz

From: Date: Thu, 11 Mar 2004 10:43:10 +0000
Subject: note 40678 deleted from features.file-upload.multiple by betz
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-66617@lists.php.net to get a copy of this message
Note Submitter: Upload multiple files(ne no) in PHP4.2.2 ---- PHP 4.2.2 running on Apache 2.0.40 (RH Linux 8.0) Sample form file <html><form action="file-upload.php" method="post" enctype="multipart/form-data"> Send these files:<br /> <input name="userfile[]" type="file" /><br /> <input name="userfile[]" type="file" /><br /> : : : : : : : : : : : : <input type="submit" value="Send files" /> </form></html> Sample upload.php file would be as shown below. This would upload all the files attached. <?PHP $directory = "/dir/files";//dir where you $size= sizeof($_FILES['userfile']['name']); for ($i = 0; $i <= $size; $i++) { $fname = $_FILES['userfile']['name'][$i]; $userf = $_FILES['userfile']['tmp_name'][$i]; if($fname!=""){ $dat = date("d,m,y"); $fp = fopen ($userf, "rb"); $fileSize = filesize($userf); $contents = fread($fp,$fileSize); fclose($fp); if ($fileSize<2000000){ $fp = fopen("$directory/$fname","wb"); fwrite($fp, $contents); } else { echo "<hr> Your file is way too big!!!<hr>"; } fclose($fp); } //if } //for ?> -Ashwini (mail4ashwini@yahoo.co.in)

« previous php.notes (#66617) next »