In the PHP file upload this paragraph, if not Ajax to achieve, the effect is not good, the user experience is not very well, below we will look at this ajax+php no refresh file upload code bar. ajax+php No refresh File upload code
ajax+php Tutorial No Refresh File upload code
<title>ajax+php No refresh File upload code</title>
file.php file
$sort = 12;
$f _type=strtolower ("swf,jpg,rar,zip,7z,iso,gif");//Set the type of file that can be uploaded
$file _size_max=200*1024*1024;//limit the maximum capacity of a single file upload
$overwrite = 0;//is allowed to overwrite the same file, 1: Allowed, 0: not allowed
$f _input= "Files";//Set up an upload domain name
foreach ($_files[$f _input]["error"] as $key = = $error) {
$up _error= "No";
if ($error = = UPLOAD_ERR_OK) {
$f _name=$_files[$f _input][' name ' [$key];//get the upload source file name
$uploaddir = './www.bkjia.c0m/';
$uploadfile = $uploaddir. Strtolower (basename ($f _name));
$tmp _type=substr (STRRCHR ($f _name, "."), 1);//Get the file name extension
$tmp _type=strtolower ($tmp _type);
if (!stristr ($f _type, $tmp _type)) {
echo "";
$up _error= "yes";
}
if ($_files[$f _input][' size '] [$key]> $file _size_max) {
echo "";
$up _error= "yes";
}
if (file_exists ($uploadfile) &&! $overwrite) {
echo "";
$up _error= "yes";
}
$string = ' abcdefghijklmnopgrstuvwxyz0123456789 ';
$rand = ";
for ($x =0; $x <12; $x + +)
$rand. = substr ($string, Mt_rand (0,strlen ($string)-1), 1);
$t =date ("Ymdhis"). substr ($gettime [0],2,6). $rand;
$attdir = "./file/";
if (!is_dir ($attdir))
{mkdir ($attdir);}
$uploadfile = $attdir. $t. ".". $tmp _type;
if ($up _error!= "yes") and (Move_uploaded_file ($_files[$f _input][' tmp_name ')
[$key], $uploadfile))) {
$_msg=$_msg. $f _name. ' Upload success n ';
}
else{
$_msg=$_msg. $f _name. ' Upload failed n ';
}
}
}
echo "";
/*
In the PHP file upload this paragraph, if not Ajax to achieve, the effect is not good, the user experience is not very well, below we will look at this ajax+php no refresh file upload code bar.
*/
?>
http://www.bkjia.com/PHPjc/630650.html www.bkjia.com true http://www.bkjia.com/PHPjc/630650.html techarticle in the php file upload this paragraph, if not Ajax to achieve, the effect is not good, the user experience is not very well, below we will look at this ajax+php no refresh file upload code bar. ...