复制代码代码如下:
文件上传
$UploadedFile=$_FILES['UploadedFile']['tmp_name'];
$UploadedFile_name=$_FILES['UploadedFile']['name'];
$isTrue=false;
if($UploadedFile)
{
$store_dir=$_SERVER['DOCUMENT_ROOT'];
$accept_overwrite = 1;
$isTrue=true;
}
$fileName = date("YmtHis").$UploadedFile_name;
if (file_exists($store_dir . $fileName))
{
echo "同じファイル名のファイルが存在します";
}
$mytype =array(".jpg",".gif",".png");
$filetype=substr($_FILES['UploadedFile']['name'],strrpos($_FILES['UploadedFile']['name'],"."));
$typecount=0;
if($isTrue)
{
for($i=0;$i{
if($filetype==$mytype[$i])
{
$typecount++;
}
}
if($typecount>0)
{
if($_FILES['UploadedFile']['size']<1048576)
{
$b=move_uploaded_file($UploadedFile,$store_dir.$fileName) ;
if($b)
{
echo "
n";
echo "翻訳文情報:
";
echo "名前:".$_FILES['UploadedFile']['name']."
n";
echo "大小:".$_FILES['UploadedFile']['size']."
n";
echo "类型:".$_FILES['UploadedFile']['type']."
n";
エコー「
n」;
echo "残留パケット库の名前:".$fileName;
エコー「
n」;
}
}
else
{
echo "文件大小不規格超过1兆。";
}
}
else
{
echo "不標準上传次类型文件!";
}
}
?>