Question

I am able to upload small files without any issues. When I try with a 150mb file, it stops unexpectedly. The following is my HTML file:

<html>
  <body>
    <form  method="post" enctype="multipart/form-data" class="form-horizontal" id="form_upload">
      <div class="control-group">
        <label class="control-label muted">IMG</label>
        <div class="controls">
          <input type="file" id="img" name="img" />
        </div>
      </div>
      <div class="control-group">
        <label class="control-label muted">MD5</label>
        <div class="controls">
          <input type="file" id="md5" name="md5" />
        </div>
      </div>
    </form>
    <div class="progress">
      <div class="bar"></div>
      <div class="percent"></div>
    </div>
  </body>
</html>

And the following is my Ajax handler: I am using the jQuery form submit plugin.

uploadFirmware:function(){
  var bar = $('.bar');
  var percent = $('.percent');
  self = this;
  var options = {
    beforeSend: function() {
      var percentVal = '0%';
      bar.width(percentVal)
      percent.html(percentVal);
    },
    uploadProgress: function(event, position, total, percentComplete) {
      var percentVal = percentComplete + '%';
      bar.width(percentVal)
      percent.html(percentVal);
    },
    complete: function(data) {
      console.log(data);
      self.showStatusMsg(1,"<b>Firmware Upload: </b> File Upload successfully");
    },
    url: '/cav_firmware/api',
    iframe: false
  };
  $("#form_upload").ajaxSubmit(options);
  return false;
}

And finally this is my PHP code. I am using CodeIgniter, but I am not using that in my code, just a classic PHP script.

public function api_post(){
  $filea = $_FILES['img'];
  $fileb = $_FILES['md5'];
  if( move_uploaded_file($filea['tmp_name'], '/home/sreeni/upload/'.$filea['name']) && move_uploaded_file($fileb['tmp_name'], '/home/sreeni/upload/'.$fileb['name'])){
    echo "Success fully upload files";
  } else {
    echo "File upload failed.";
  }
}

All this is fine. My issue is only with uploading a 150 MB file. I am getting the following error when I try to upload my MD5 and IMG files:

<div style="border:1px solid #990000;padding-left:20px;margin:0 0 10px 0;">
  <h4>A PHP Error was encountered</h4>
  <p>Severity: Notice</p>
  <p>Message:  Undefined index: img</p>
  <p>Filename: controllers/cav_firmware.php</p>
  <p>Line Number: 30</p>
</div>
<div style="border:1px solid #990000;padding-left:20px;margin:0 0 10px 0;">
  <h4>A PHP Error was encountered</h4>
  <p>Severity: Notice</p>
  <p>Message:  Undefined index: md5</p>
  <p>Filename: controllers/cav_firmware.php</p>
  <p>Line Number: 31</p>
</div>File upload failed.

I changed my php.ini to the maximum size 200 MB (memory limit) in /etc/php5/apache2/php.ini.

What am I doing wrong here? Do I need to specify my files are MD5 and IMG (firmware image files)? Any help?

Was it helpful?

Solution

check for your maximum execution time of script in php.ini default time is 30seconds.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top