$sort = 12;
$f _type=strtolower ("swf,jpg,rar,zip,7z,iso,gif");//Set the file types that can be uploaded
$file _size_max=200*1024*1024;//Limit the maximum size of a single file upload
$overwrite = 0;//is allowed to overwrite the same file, 1: Allowed, 0: not allowed
$f _input= "Files";/set up to upload the 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 upload source filename
$uploadfile = $uploaddir. Strtolower (basename ($f _name));
$tmp _type=substr (STRRCHR ($f _name, "."), 1)//Get file name extension
$tmp _type=strtolower ($tmp _type);
if (!stristr ($f _type, $tmp _type)) {
echo "<script>alert (' Sorry, can't upload". $tmp _type. " Format file, ". $f _name." File upload failed! ') </script> ";
$up _error= "yes";
}
if ($_files[$f _input][' size '] [$key]> $file _size_max) {
echo "<script>alert (' Sorry, you uploaded the file". $f _name. "Capacity is". Round ($_files[$f _input]
[' Size '] [$key]/1024). " KB, greater than the specified ". ($file _size_max/1024). " KB, upload failed! ') </script> ";
$up _error= "yes";
}
if (file_exists ($uploadfile) &&! $overwrite) {
echo "<script>alert (' Sorry, file". $f _name. "Already exist, upload failed! ') </script> ";
$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 ';
}
else{
$_msg=$_msg. $f _name. ' Upload failed ';
}
}
}
echo "<script>window.parent.finish" ("$_msg."); </script> ";
?>
Second File Upload code
<?php
$destination _path = '.. /.. /upfile/jianjulogo/';//getcwd (). Directory_separator;
$result = 0;
$target _path = $destination _path. basename ($_files[' myfile '] [' name ']);
if (@move_uploaded_file ($_files[' myfile '] [' tmp_name '], $target _path)) {
$result = 1;
}
echo $target _path;
Sleep (1);
?>
<script language= "Web Effects" type= "Text/javascript" >window.top.window.stopupload (<?php echo $result; <?= $target _path?> ');</script>