Welcome Guest, Not a member yet? Register   Sign In
andrew valums ajax upload to codeigniter
#16

[eluser]mabright[/eluser]
seibelj, I am trying to get my upload working based on you instructions. I am receiving a "Failed" message. I select a file, I see the loading image and the file name and size, then "Failed".

Controller
Code:
public function upload()
{
  $this->load->library('qquploadedfilexhr');
  
  // list of valid extensions, ex. array("jpeg", "xml", "bmp")
  $allowedExtensions = array('jpg','bmp','png','gif');
  // max file size in bytes
  $sizeLimit = 1 * 1024 * 1024;
  
  $uploader = new qqFileUploader($allowedExtensions, $sizeLimit);
  $result = $uploader->handleUpload('../../img/uploads');
  
  // to pass data through iframe you will need to encode all html tags
  echo htmlspecialchars(json_encode($result), ENT_NOQUOTES);
}

upload.js
Code:
$(document).ready(function() {
        var uploader = new qq.FileUploader({
            // pass the dom node (ex. $(selector)[0] for jQuery users)
            element: document.getElementById('file-uploader'),
            // path to server-side upload script
            action: 'http://www.mysite.com/ajax/upload'
        });
    });

View
Code:
<div id="file-uploader">
       &lt;?php
        echo (isset($error))? $error : '';
        $attributes = array('id' => 'imageform');
        echo form_open_multipart('ajax/upload', $attributes);
       ?&gt;
       <p><strong>Upload a Picture</strong></p>
       &lt;input type="file" name="photoimg" id="photoimg" size="25"/&gt;&lt;br>
       &lt;/form&gt;
      </div>


Messages In This Thread
andrew valums ajax upload to codeigniter - by El Forum - 12-15-2010, 03:10 AM
andrew valums ajax upload to codeigniter - by El Forum - 12-15-2010, 07:00 AM
andrew valums ajax upload to codeigniter - by El Forum - 01-05-2011, 02:56 PM
andrew valums ajax upload to codeigniter - by El Forum - 04-20-2011, 11:16 PM
andrew valums ajax upload to codeigniter - by El Forum - 04-21-2011, 01:47 AM
andrew valums ajax upload to codeigniter - by El Forum - 04-21-2011, 08:52 AM
andrew valums ajax upload to codeigniter - by El Forum - 05-15-2011, 09:44 AM
andrew valums ajax upload to codeigniter - by El Forum - 05-18-2011, 01:03 AM
andrew valums ajax upload to codeigniter - by El Forum - 05-18-2011, 02:56 AM
andrew valums ajax upload to codeigniter - by El Forum - 05-19-2011, 06:24 AM
andrew valums ajax upload to codeigniter - by El Forum - 05-19-2011, 06:50 AM
andrew valums ajax upload to codeigniter - by El Forum - 05-19-2011, 06:56 AM
andrew valums ajax upload to codeigniter - by El Forum - 05-23-2011, 11:18 AM
andrew valums ajax upload to codeigniter - by El Forum - 05-28-2011, 05:58 AM
andrew valums ajax upload to codeigniter - by El Forum - 05-28-2011, 06:05 AM
andrew valums ajax upload to codeigniter - by El Forum - 01-26-2012, 04:27 PM
andrew valums ajax upload to codeigniter - by El Forum - 01-27-2012, 05:43 PM
andrew valums ajax upload to codeigniter - by El Forum - 02-01-2012, 08:07 AM
andrew valums ajax upload to codeigniter - by El Forum - 02-01-2012, 08:18 AM
andrew valums ajax upload to codeigniter - by El Forum - 02-01-2012, 09:09 AM
andrew valums ajax upload to codeigniter - by El Forum - 02-01-2012, 10:23 AM



Theme © iAndrew 2016 - Forum software by © MyBB