0
我正在使用PHP为我的私人Android应用程序进行某种更新管理。该计划是我有一个HTML表单,我选择apk文件和应用程序版本。当我将应用上传到我的服务器时,它将被放置在apk文件夹中并重新命名。问题是我无法将文件上传到服务器。它不断显示“有错误”。 Apk文件夹有777个权限。PHP没有上传文件到服务器
HTML表单:
<form action="android_u.php" method="post" enctype="multipart/form-data">
<table cellspacing="0" border="0" width="680" style="margin-top:25px;">
<tr>
<td><b>APK file:</b></td>
<td><input type="file" name="apk" placeholder="APK file..." /></td>
</tr>
<tr>
<td><b>Version:</b></td>
<td><input type="text" name="version" placeholder="Version..." /> (Example: 1.1)</td>
</tr>
</table>
<input type="image" id="upload" style="margin-left: 580px;" src="templates/images/spacer.png" />
</form>
PHP代码:
$version = $_REQUEST['version'];
$ver = str_replace(".", "-", $version);
$target_path = "/apk/ind-" . $ver . ".apk";
$file = "ind-" . $ver . ".apk";
if(move_uploaded_file($_FILES['apk']['tmp_name'], $target_path)) {
$msg = "<div class='msg2'>File uploaded</div>";
$day = date("j");
$month = date("n");
$year = date("Y");
$hour = date("G");
$minute = date("i");
$query = "INSERT INTO android (version, user_id, prenosi, file, year, month, day, hour, minute) VALUES ('$verzija', '$id', '0', '$file', '$year', '$month', '$day', '$hour', '$minute')";
mysql_query($query);
} else {
$msg = "<div class='msg2'>Error</div>";
}
尝试转储$ _FILES ['apk'] ['error']以查看是否有错误代码..您的问题可能与上传大小有关。阅读更多关于错误代码在这里http://php.net/manual/en/features.file-upload.errors.php – lostsource
转储显示int(1),目标文件夹是可写的,文件大小小于400 kb – Soriyyx
错误1 = *上传的文件超过了php.ini中的upload_max_filesize指令* – lostsource