php图片文件上传详细分析_PHP教程
Jul 20, 2016 am 11:09 AM
upload_err_ok no error occurred.
上传成功
upload_err_ini_size the uploaded file exceeds the maximum value specified in the php教程.ini file.
超出最大上传尺寸
upload_err_form_size the uploaded file exceeds the maximum value specified by the max_file_size hidden widget.
超出form设置最大上传尺寸
upload_err_partial the file upload was canceled and only part of the file was uploaded.
upload_err_nofile no file was uploaded.
未上传文件
a simple file upload form
action="" method="post">
实例一
]
a file upload script
if ( isset( $_files['fupload'] ) ) {print "name: ". $_files['fupload']['name'] ."
";
print "size: ". $_files['fupload']['size'] ." bytes
";
print "temp name: ".$_files['fupload']['tmp_name'] ."
";
print "type: ". $_files['fupload']['type'] ."
";
print "error: ". $_files['fupload']['error'] ."
";if ( $_files['fupload']['type'] == "image/gif" ) {
$source = $_files['fupload']['tmp_name'];
$target = "upload/".$_files['fupload']['name'];
move_uploaded_file( $source, $target );// or die ("couldn't copy");
$size = getimagesize( $target );$imgstr = "
";
$imgstr .= " alt="uploaded image" />
print $imgstr;
}
}
?>
action="" method="post">
文件上传实例二
$maxsize=28480;
if (!$http_post_vars['submit']) {
$error=" ";
}
if (!is_uploaded_file($http_post_files['upload_file']['tmp_name']) and !isset($error)) {
$error = "you must upload a file!
";
unlink($http_post_files['upload_file']['tmp_name']);
}
if ($http_post_files['upload_file']['size'] > $maxsize and !isset($error)) {
$error = "error, file must be less than $maxsize bytes.
";
unlink($http_post_files['upload_file']['tmp_name']);
}
if (!isset($error)) {
move_uploaded_file($http_post_files['upload_file']['tmp_name'],
"uploads/".$http_post_files['upload_file']['name']);
print "thank you for your upload.";
exit;
}
else
{
echo ("$error");
}
?>
method="post" enctype="multipart/form-data">
choose a file to upload:

인기 기사

인기 기사

뜨거운 기사 태그

메모장++7.3.1
사용하기 쉬운 무료 코드 편집기

SublimeText3 중국어 버전
중국어 버전, 사용하기 매우 쉽습니다.

스튜디오 13.0.1 보내기
강력한 PHP 통합 개발 환경

드림위버 CS6
시각적 웹 개발 도구

SublimeText3 Mac 버전
신 수준의 코드 편집 소프트웨어(SublimeText3)

뜨거운 주제











Ubuntu 및 Debian용 PHP 8.4 설치 및 업그레이드 가이드

PHP 개발을 위해 Visual Studio Code(VS Code)를 설정하는 방법
