I have installed the EAjaxUpload Extension. Could not find any entries using search - so a new topic. Was not able to post against the entry in Extensions.
The page prompts for a file, it downloads with progress but at the end it just says "Failed."
I have tried placing "upload" folders everywhere in case I created in the wrong directory. I cannot much information on this extension, but I would like to use this as it seems to be the most compact.
Hi, thanks for the assistance. I have a simple site that I requires an upload feature. I have loaded the extension as instructed. The upload button appears on the view and I can select a file. It goes though the process of uploading and then it lists the file with a "Failed." response. I have not been able to debug as the transaction happens outside of YIi/PHP and is between the OS and the Browser.
I have tried to add "upload" directory in a number of spots but cannot find any instruction as to where exactly to locate. The other question is where is the temporary file saved? Does another directory need to be created with write permissions?
I had to include the folder and index.php (/narta/index.php/accreditation/upload) and got the following;
[uploader] responseText = {‘error’:‘increase post_max_size and upload_max_filesize to 10M’}
Here are my configuration files;
{view}.php
<?php $this->widget('ext.EAjaxUpload.EAjaxUpload',
array(
'id'=>'uploadFile',
'config'=>array(
'action'=>'/narta/index.php/accreditation/upload',
'allowedExtensions'=>array("jpg","jpeg","gif","pdf","png"), //and etc...
'sizeLimit'=>10*1024*1024,// maximum file size in bytes
'minSizeLimit'=>1,// minimum file size in bytes
'onComplete'=>"js:function(id, fileName, responseJSON){ alert(fileName); }",
'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); }"
)
));
?>
AccreditationController.php
public function actionUpload()
{
Yii::import("ext.EAjaxUpload.qqFileUploader");
$folder='upload/';// folder for uploaded files
$allowedExtensions = array("jpg","jpeg","gif","png","pdf"); // and etc...
$sizeLimit = 10 * 1024 * 1024;// maximum file size in bytes
$uploader = new qqFileUploader($allowedExtensions, $sizeLimit);
$result = $uploader->handleUpload($folder);
$result=htmlspecialchars(json_encode($result), ENT_NOQUOTES);
echo $result;// it's array
}
This message: “[uploader] responseText = {‘error’: ‘increase post_max_size and upload_max_filesize to 10M’}” indicates that your server are restrictions on the size of an uploaded file.
Look in the php.ini: post_max_size, upload_max_filesize
Try to reduce the value of "sizeLimit" in EAjaxUpload.
i am newbie in yiiframework i installed your extension its working fine and thanks for the gr8 extension but
i have one issue i wanted to store all the file name in to database so not understand how to get all the file names and store it while submitting the form
$this->widget('ext.EAjaxUpload.EAjaxUpload',
array(
'id'=>'uploadFile',
'config'=>array(
'action'=>Yii::app()->baseUrl.'/content/upload',
'allowedExtensions'=>array("jpg"),//array("jpg","jpeg","gif","exe","mov" and etc...
'sizeLimit'=>10 * 1024 * 1024,// maximum file size in bytes
'minSizeLimit'=>1*1024,// minimum file size in bytes
'onComplete'=>"js:function(id, fileName, responseJSON){ alert(fileName); }",
'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); }"
)
));
This extension successfully upload image but does not enter the name of file in db. In other extensions(that I use in same form for other purposes), I simply include properities of this field:
"model"=>$model, # Data-Model
"attribute"=>'banner', # Attribute in the Data-Model
and after pressing a button Save, script saves information in corresponding field in db.
But here I haven’t that option. How I could solve this?
I try to use this extension but i only get "failed" when i upload an image
here is my code
UploadController.php
class UploadController extends Controller
{
public function actionIndex()
{
$this->render('index');
}
public function actionUpload()
{
Yii::import("ext.EAjaxUpload.qqFileUploader");
$folder=Yii::app()->baseUrl.'upload/';// folder for uploaded files
$allowedExtensions = array("jpg");//array("jpg","jpeg","gif","exe","mov" and etc...
$sizeLimit = 10 * 1024 * 1024;// maximum file size in bytes
$uploader = new qqFileUploader($allowedExtensions, $sizeLimit);
$result = $uploader->handleUpload($folder);
$result=htmlspecialchars(json_encode($result), ENT_NOQUOTES);
echo $result;// it's array
}
}
site/index.php
<? $this->widget('ext.EAjaxUpload.EAjaxUpload',
array(
'id'=>'uploadFile',
'config'=>array(
'action'=>Yii::app()->baseUrl.'UploadController',
'allowedExtensions'=>array("jpg"),//array("jpg","jpeg","gif","exe","mov" and etc...
'sizeLimit'=>10*1024*1024,// maximum file size in bytes
'minSizeLimit'=>1*1*1024,// minimum file size in bytes
//'folder'=>'../../images/',
//'onComplete'=>"js:function(id, fileName, responseJSON){ alert(fileName); }",
//'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); }"
),
)); ?>
I alsoo had some issues with this extension, and was about to give up, but finally managed to get it working, here are my steps, for those who need help:
Make sure your upload folder exists and has the right chmod properties (set it on 777 first, and if you got it working set it on 775). the upload folder should be in the root of the site.
I had issues with "file not found controller/upload/". My Yii app was in a subfolder for testing. Once I put it in the root (in my case I put it in a subdomain folder). It worked. This could be a pathing issue from my side. but it worked.
Adjust the php.ini with:
upload_max_filesize = 10M
post_max_size = 10M
if you dont have a php.ini. Create one and put it in the root of your site (or wherever your hostingprovider wants it).
This is my code:
the view (index.php in my case)
<? $this->widget('ext.EAjaxUpload.EAjaxUpload',
array(
'id'=>'uploadFile',
'config'=>array(
'action'=>'/Builder/CreateThumb',
'allowedExtensions'=>array("jpg"),//array("jpg","jpeg","gif","exe","mov" and etc...
'sizeLimit'=>10*1024*1024,// maximum file size in bytes
'minSizeLimit'=>1024,// minimum file size in bytes
'onComplete'=>"js:function(id, fileName, responseJSON){ console.log(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); }"
)
)); ?>
the controller (in my case BuilderController)
<?php
class BuilderController extends Controller
{
public function actionCreateThumb(){
Yii::import("ext.EAjaxUpload.qqFileUploader");
$folder='var/projects/';// folder for uploaded files
$allowedExtensions = array("jpg");//array("jpg","jpeg","gif","exe","mov" and etc...
$sizeLimit = 10 * 1024 * 1024;// maximum file size in bytes
$uploader = new qqFileUploader($allowedExtensions, $sizeLimit);
$result = $uploader->handleUpload($folder);
$result=htmlspecialchars(json_encode($result), ENT_NOQUOTES);
echo $result;// it's array
}
}