2013-02-06 41 views
-1

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

预先感谢您。

+0

这是一个初学者的问题,只是找到任何教程上传图片与PHP .. – phpalix

+0

对不起,男人。但我是初学者,无法找到我的问题的答案。 –

回答

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."; 
} 
} 
相关问题