0

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>";
}
8
  • 3
    try dumping $_FILES['apk']['error'] to see if there's an error code.. your issue could be related to upload size. read more about error codes here php.net/manual/en/features.file-upload.errors.php Commented Dec 9, 2012 at 16:06
  • dump displays int(1), destination folder is writeable and file size is less than 400 kb Commented Dec 9, 2012 at 16:12
  • 1
    error 1 = The uploaded file exceeds the upload_max_filesize directive in php.ini Commented Dec 9, 2012 at 16:13
  • 1
    target_path = "/apk/ind... you know that's root/apk/ind...? Commented Dec 9, 2012 at 16:14
  • In phpinfo() is upload_max_filesize displayed as 50MB, file is only 400 kB Commented Dec 9, 2012 at 16:14

1 Answer 1

1

Problem solved, thank you for helping.

I changed upload_max_filesize in php.ini from 50MB to 50M and it works.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.