php tutorial multi-file upload component
< ;/head>
< !--Text used in the video-->
这个选择框的数据将以post形式和图片一起传送到服务器
改变窗口:高
php processing file
// Note: use When uploading components, you cannot use $_files["filedata"]["type"] to determine the file type
mb_http_input("utf-8");
mb_http_output("utf-8");//--------------------------------------------- --------------------------------------------------
//Instance code when the component sets a.md5file to 2 and 3if(getget('access2008_cmd')=='2'){ // Submit the md5 verified file information for verification
//getget("access2008_file_name") 'File name
//getget("access2008_file_size") 'File size in bytes
//getget("access2008_file_type") 'File type such as .gif .png
//getget("access2008_file_md5") 'The md5 signature of the file
die('0'); //Return command 0 = Start uploading the file, 2 = Do not upload the file, the front desk directly displays the upload completion
}
if(getget('access2008_cmd')=='3'){ //Submit file information for verification
//getget("access2008_file_name") 'File name
//getget("access2008_file_size ") 'File size in bytes
//getget("access2008_file_type") 'File type such as .gif .png
die('1'); //Return command 0 = Start uploading files ,1 = Submit the file information after md5 verification for verification, 2 = Do not upload the file, the front desk directly displays the upload completion
}
//----------------- -------------------------------------------------- --------------------------$type=filekzm($_files["filedata"]["name"]) ;
if ((($type == ".gif")
|| ($type == ".png")
|| ($type == ".jpeg")
|| ($type == ".jpg")
|| ($type == ".bmp"))
&& ($_files["filedata"]["size"] < 200000))
{
if ($_files["filedata"]["error"] > 0)
{
echo "Return error: " . $_files["filedata"]["error" ] . "
";
}
else
{
echo "Uploaded files: " . $_files["filedata"]["name"] . "< br />";
echo "File type: " . $type . "
";
echo "File size: " . ($_files["filedata"]["size" ] / 1024) . " kb
";
echo "Temporary file: " . $_files["filedata"]["tmp_name"] . "
";if (file_exists( $_files["filedata"]["name"]))
{
echo $_files["filedata"]["name"] . " already exists. ";
}
else
{
move_uploaded_file($_files["filedata"]["tmp_name"],
'./'.$_files["filedata"]["name"]);
echo "stored in: " . $_files["filedata"]["name"]."
";
echo "md5 validation:".getget("access2008_file_md5")."< ;br />";
echo "
Upload successful! What you selected is".getpost("select")."--".getpost("select2" )."";
}
}
}
else
{
echo "Upload failed, please check whether the file type and file size meet the standards< br />File type: ".$type.'
File size:'.($_files["filedata"]["size"] / 1024) . " kb";
}
function filekzm($a)
{
$c=strrchr($a,'.');
if($c)
{
return $c;
}else{
return '';
}
}function getget($v)// Get get
{
if(isset($_get [$v]))
{
return $_get[$v];
}else{
return '';
}
}function getpost ($v)// Get post
{
if(isset($_post[$v]))
{
return $_post[$v];
}else{
return '';
}
}
?>
Source code package download
http://down.php100.com/php/2011/0311/22880.html