I am making some kind of update management for my private android app with PHP. The plan is that I have a HTML form where I select apk file and version of application. When I upload app to my server it would be placed in apk folder and renamed. The problem is that I can't get file uploaded to server. It keeps showing "There is error". Apk folder have 777 rights.
HTML form:
<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 code:
$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>";
}