PHP ajax No Refresh file upload source download _php Tutorial

Source: Internet
Author: User
Tags php file upload php source code upload php
This is a can upload 10 files at the same time Php+ajax no refreshing upload source, and also with the upload progress bar oh, good crap don't say more like to download it.

This is a can upload 10 files at the same time Php+ajax no refreshing upload source, and also with the upload progress bar oh, good crap don't say more like to download it.





<title>No refresh File upload system</title>






file.php File upload php source code.






<title>Untitled Document</title>


$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

$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 "";
?>



http://www.bkjia.com/PHPjc/445040.html www.bkjia.com true http://www.bkjia.com/PHPjc/445040.html techarticle This is a can upload 10 files at the same time Php+ajax no refreshing upload source, and also with the upload progress bar oh, good crap don't say more like to download it. This is a can ...

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.