Hi,
In order to upload a image file, using ajax, I’m using an extension called eajaxupload. It seems very easy to use but hard to debug.
Every time I upload a file, the only thing happening is a print of the file name and ‘Failed’, next to that.
No server errors.
The php.ini has upload_max_filesize = 10M and post_max_size = 10M.
The folder permissions is 777.
This is how that is in the view:
<?
$this->widget('ext.EAjaxUpload.EAjaxUpload', array(
'id' => 'uploadFile',
'config' => array(
'action' => Yii::app()->createUrl('mestre/upload'),
'allowedExtensions' => array("jpg", "png", "gif", "jpeg"), //array("jpg","jpeg","gif","exe","mov" and etc...
'sizeLimit' => 1 * 1024 * 1024, // maximum file size in bytes
'minSizeLimit' => 1, // minimum file size in bytes
'onComplete' => "js:function(id, fileName, responseJSON){ alert(responseJSON); }",
'messages' => array(
'typeError' => "{file} has invalid extension. Only {extensions} are allowed.",
'sizeError' => "{file} is too large, maximum file size is {sizeLimit}.",
'minSizeError' => "{file} is too small, minimum file size is {minSizeLimit}.",
'emptyError' => "{file} is empty, please select files again without it.",
'onLeave' => "The files are being uploaded, if you leave now the upload will be cancelled."
),
'showMessage' => "js:function(message){ alert(message); }"
)
));
?>
And this is how that is in the controller:
Yii::import("ext.EAjaxUpload.qqFileUploader");
$allowedExtensions = array("jpg", "jpeg", "gif", "png"); //array("jpg","jpeg","gif","exe","mov" and etc...
$sizeLimit = 1 * 1024 * 1024; // maximum file size in bytes
$uploader = new qqFileUploader($allowedExtensions, $sizeLimit);
$result = $uploader->handleUpload($folder);
$result = htmlspecialchars(json_encode($result), ENT_NOQUOTES);
$foto_name = $result['filename'];
$this->_foto_name = $foto_name;
Can some one see the bug here? How should I debug this?
Thanks