php圖片檔案上傳詳細分析_PHP教程

來源:互聯網
上載者:User
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




執行個體一

]

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 .= "src="$target" alt="uploaded image" />

";

print $imgstr;
}
}
?>



檔案上傳執行個體二

$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");
}
?>







http://www.bkjia.com/PHPjc/444783.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/444783.htmlTechArticleupload_err_ok no error occurred. 上傳成功 upload_err_ini_size the uploaded file exceeds the maximum value specified in the php教程.ini file. 超出最大上傳尺寸 upload_e...

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    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.