我正在制作应用程序并希望用户能够通过智能手机将照片固定到网站上。目前代码正在使用iPhone,但由于某些原因我无法让它在Android上运行,即使使用后期测试服务器(http://www.posttestserver.com)它也可以完美运行!
我现在无法弄清楚可能出现的问题。
这是我的代码:
<?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();
?>
感谢您的帮助!
答案 0 :(得分:0)
确保您在表单上设置了enctype='multiform/data'