error_reporting(7); // Max size PER file in KB, not bytes for simplicity! $max_file_size="1000024"; // Max size for all files COMBINED in KB, not bytes for simplicity! $max_combined_size="2000048"; //How many file uploads do you want to allow at a time? $file_uploads="7"; //The name of the uploader.. $websitename="آپلود سنتر خبرگزاری فارسی سوپرسل"; // Use random file names? true=yes (recommended), false=use original file name. Random names will help prevent overwritting of existing files! $random_name=true; // Please keep the array structure. $allow_types=array("jpg","gif","png","zip","rar","txt","doc","apk","mp4","mp3"); // Path to files folder. If this fails use $fullpath below. With trailing slash $folder="./uploads/"; // Full url to where files are stored. With Trailing Slash $full_url="http://www.androidfree.ir/uploads/"; // Only use this variable if you wish to use full server paths. Otherwise leave this empty! With trailing slash $fullpath=""; //Use this only if you want to password protect your uploads. $password=""; /* //================================================================================ * ! ATTENTION ! //================================================================================ : Don't edit below this line unless you know some php. Editing some variables or other stuff could cause undeseriable results!! */ // MD5 the password.. why not? $password_md5=md5($password); // If you set a password this is how they get verified! If($password) { If($_POST['verify_password']==true) { If(md5($_POST['check_password'])==$password_md5) { setcookie("phUploader",$password_md5,time()+86400); sleep(1); //seems to help some people. header("Location: http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']); exit; } } } // The password form, if you set a password and the user has not entered it this will show. $password_form=""; If($password) { If($_COOKIE['phUploader']!=$password_md5) { $password_form="
\n"; } } // Function to get the extension a file. function get_ext($key) { $key=strtolower(substr(strrchr($key, "."), 1)); // Cause there the same right? $key=str_replace("jpeg","jpg",$key); return $key; } $ext_count=count($allow_types); $i=0; foreach($allow_types AS $extension) { //Gets rid of the last comma for display purpose.. If($i <= $ext_count-2) { $types .="*.".$extension.", "; } Else { $types .="*.".$extension; } $i++; } unset($i,$ext_count); // why not $error=""; $display_message=""; $uploaded==false; // Dont allow post if $password_form has been populated If($_POST['submit']==true AND !$password_form) { For($i=0; $i <= $file_uploads-1; $i++) { If($_FILES['file']['name'][$i]) { $ext=get_ext($_FILES['file']['name'][$i]); $size=$_FILES['file']['size'][$i]; $max_bytes=$max_file_size*1024; // For random names If($random_name){ $file_name[$i]=time()+rand(0,100000).".".$ext; } Else { $file_name[$i]=$_FILES['file']['name'][$i]; } //Check if the file type uploaded is a valid file type. If(!in_array($ext, $allow_types)) { $error.= "فایل ناشناخته ".$_FILES['file']['name'][$i].", شما فقط اجازه آپلود این فایل ها رو دارید ".$types."فایل های شما آپلود شد | |
For($i=0; $i <= $file_uploads-1; $i++) { If($_FILES['file']['name'][$i]) { $file=$i+1; Echo("فایل ".$file." : ".$full_url.$file_name[$i]." \n"); } } ?> بازگشت |