A simple php file upload source code

Source: Internet
Author: User
Tags file upload php file upload
The code is as follows Copy Code

$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 "returned an error:". $_files["Filedata" ["Error"]. "<br/>";
}
Else
{
echo "uploaded file:". $_files["Filedata" ["Name"]. "<br/>";
echo "File type:". $type. "<br/>";
echo "File size:". ($_files["Filedata"] ["size"]/1024). "Kb<br/>";
echo "Temp file:". $_files["Filedata" ["Tmp_name"]. "<br/>";

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"]. " <br/> ";
echo "MD5 efficacy:". Getget ("Access2008_file_md5"). " <br/> ";
echo "<br/> Upload success!" Your choice is <font color= ' #ff0000 ' > '. Getpost ("select"). " </font>--<font color= ' #0000ff ' > '. Getpost ("Select2"). " </font> ";
}
}
}
Else
{
echo "Failed to upload, please check that file type and file size conform to the standard <br/> file type:". $type. ' <br/> File Size: '. ($_files["Filedata"] ["size"]/1024). "KB";
}

function Filekzm ($a)
{
$c =STRRCHR ($a, '. ');
if ($c)
{
return $c;
}else{
Return ";
}
}

function Getget ($v)//Get gets
{
if (Isset ($_get[$v]))
{
return $_get[$v];
}else{
Return ";
}
}

function Getpost ($v)//Get Post
{
if (Isset ($_post[$v]))
{
return $_post[$v];
}else{
Return ";
}
}
?>

SOURCE download address.
Http://down.111cn.net/php/2010/1027/21454.html

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.