This function is to upload multiple file to your webserver. Don't forget to 1.CHMOD 777 to the directory where the file being uploaded. 2. Make sure that directory is not under your web visitor directory.
By : hermawan
<?php /*********************************************** * Snippet Name : File Uploader * * Scripted By : Hermawan Haryanto * * Website : http://hermawan.com * * Email : hermawan@codewalkers.com * * License : GPL (General Public License) * ***********************************************/ $numoffile = 5; // Fix path of your file to be uploaded, don't forget to CHMOD 777 to this folder $file_dir = "/home/webs/dmonster.com/subdomain/files/"; if ($_POST) { for ($i=0;$i<$numoffile;$i++) { if (trim($_FILES['myfiles']['name'][$i])!="") { $newfile = $file_dir.$_FILES['myfiles']['name'][$i]; move_uploaded_file($_FILES['myfiles']['tmp_name'][$i], $newfile); $j++; } } } if (isset($j)&&$j>0) print "Your file(s) has been uploaded.<br>"; print "<form method='post' enctype='multipart/form-data'>"; for($i=0;$i<$numoffile;$i++) { print "<input type='file' name='myfiles[]' size='30'><br>"; } print "<input type='submit' name='action' value='Upload'>"; print "</form>"; ?>
DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.