M
M
Matthew Stafford2018-04-09 16:27:45
PHP
Matthew Stafford, 2018-04-09 16:27:45

Upload and download .APK file. How to solve the problem?

Hello! Faced this problem:

  • I upload a file with the .APK extension (application installer for Android devices) to the server via a PHP script, the upload is successful.
  • When downloading this file on a mobile device from a browser, from the download page, it downloads successfully, but does not want to run on a mobile device. Writes that the file could not be opened.

Perhaps this is due to some error while uploading the file?
<?php

  require_once('system/mysql.php');

  ini_set('upload_max_filesize', '10M'); 
  if ($_SERVER['REQUEST_METHOD'] == "POST" ) {
    if ($_FILES['inputfile']['error'] == UPLOAD_ERR_OK) {
      $destiation_dir = dirname(__FILE__) .'/uploads/app-release.apk';
      if (move_uploaded_file($_FILES['inputfile']['tmp_name'], $destiation_dir)) {
        echo 'File Uploaded';
        
        $version = $_POST['version'];
        $ip = $_SERVER['REMOTE_ADDR'];
        $time = date('Y-m-d H:i:s');
        
        $sql = mysql_query("UPDATE `application` SET `version`='$version', `time`='$time', `ip`='$ip'");
      } else {
        echo 'File not uploaded';
      }
    } else {
      switch ($_FILES['inputfile']['error']) {
        case UPLOAD_ERR_FORM_SIZE:
        case UPLOAD_ERR_INI_SIZE:
        echo 'File Size exceed';
        brake;
        case UPLOAD_ERR_NO_FILE:
        echo 'FIle Not selected';
        break;
        default:
        echo 'Something is wrong';
      }
    }
  }
  
?>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
FreudVans, 2018-04-09
@FreudVans

MB because the file size limit is

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question