-1

我需要将拍摄的照片上传到 PHP 服务器,但我不知道如何传递此图像(位图)和其他信息,如名称和登录名,并使用 $_FILES[] 在服务器端获取它们。

先感谢您。

4

1 回答 1

0
 $target = "folder_name/"; 

 $target = $target . basename( $_FILES['uploaded']['name']) ; 
 $ok=1; 
 echo "<pre>"; print_r($_FILES);echo "</pre>";
 echo $target."<br>";
 $uploaded_size=$_FILES['uploaded']['size'];
 $uploaded_type=$_FILES['uploaded']['type'];
 //This is our size condition 
 if ($uploaded_size > 350000) 
 { 
 echo "Your file is too large.<br>"; 
 $ok=0; 
 } 

 //This is our limit file type condition 
 if ($uploaded_type !="image/bmp") 
 { 
 echo "No PHP files<br>"; 
 $ok=0; 
 } 

 //Here we check that $ok was not set to 0 by an error 
 if ($ok==0) 
 { 
 echo "Sorry your file was not uploaded"; 
 } 

 //If everything is ok we try to upload it 
 else 
 { 
 if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) 
 { 
 echo "<b>The file ". basename( $_FILES['uploaded']['name']). " has been uploaded</b>"; 
 } 
 else 
 { 
 echo "Sorry, there was a problem uploading your file."; 
 } 
 } 
于 2013-02-06T12:02:30.177 回答