2013-02-06 38 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."; 
} 
} 
相關問題