0
我正在構建一個應用程序,並希望用戶能夠將照片從他們的智能手機固定到網站。目前代碼是從iPhone開始工作的,但由於某些原因,我無法從Android開始工作,即使使用後測試服務器(http://www.posttestserver.com),它的工作原理完美無瑕!PHP的POST文件上傳不工作..不知道有什麼不對?
我只是無法弄清楚此時可能會出現什麼問題。
這是我的代碼:
<?php
include_once('db.php');
include_once('hfk_utils.php');
if ($_POST) {
if ($_FILES['imgfile']['error'] == 0) {
$filepath = UPLOAD_PATH.$_FILES['imgfile']['name'];
$uri = UPLOAD_URI_PATH.$_FILES['imgfile']['name'];
$url = URL_BASE_TRUE . '/' . $uri;
$thumb = URL_BASE_TRUE . '/' . UPLOAD_URI_PATH. 'thumbs/' . $_FILES['imgfile'] ['name'];
$timestamp = date('Y-m-d H:i:s');
move_uploaded_file($_FILES['imgfile']['tmp_name'],$filepath);
createThumbs(UPLOAD_PATH, UPLOAD_THUMB_PATH, 100);
$sql = mysql_query('INSERT INTO hfk_images (rid,uri,url,thumbnail) VALUES ("'.$_POST['rid'].'","'.$uri.'","'.$url.'","'.$thumb.'")');
$iid = mysql_insert_id();
mysql_query('INSERT INTO hfk_nodes (rid,author,text,iid,timestamp) VALUES ("'.$_POST['rid'].'","'.$_POST['author'].'","'.$_POST['title'].'","'.$iid.'","'.$timestamp. '")');
} else {
print_r($_FILES);
print 'Cant Upload Image';
}
} else {
print 'Cant Upload Image';
}
die();
?>
感謝所有幫助!
你可以嘗試從iPhone發佈相同數據和android,然後檢查上posttestserver –
它顯示了什麼錯誤或響應的差異呢? –