> php教程 > php手册 > 본문

php图片文件上传详细分析

WBOY
풀어 주다: 2016-06-06 19:59:36
원래의
1583명이 탐색했습니다.

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

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 = "

php图片文件上传详细分析          $imgstr .= "src="$target" 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:

   
   

   


爱分享 ? php图片文件上传详细分析

http://www.ihref.com/read-7059.html

관련 라벨:
원천:php.cn
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
인기 추천
인기 튜토리얼
더>
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿