简体   繁体   English

PHP未将文件上传到服务器

[英]PHP not uploading file to server

I am making some kind of update management for my private android app with PHP. 我正在使用PHP为我的私人android应用程序进行某种更新管理。 The plan is that I have a HTML form where I select apk file and version of application. 计划是我有一个HTML表单,在其中选择apk文件和应用程序版本。 When I upload app to my server it would be placed in apk folder and renamed. 当我将应用程序上传到服务器时,它将放置在apk文件夹中并重命名。 The problem is that I can't get file uploaded to server. 问题是我无法将文件上传到服务器。 It keeps showing "There is error". 它一直显示“有错误”。 Apk folder have 777 rights. Apk文件夹具有777权限。

HTML form: 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 code: 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>";
}

Problem solved, thank you for helping. 问题已解决,谢谢您的帮助。

I changed upload_max_filesize in php.ini from 50MB to 50M and it works. 我将php.ini中的upload_max_filesize从50MB更改为50M,它可以工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM