Well, it had been four days since i posted here. Still waiting for guidance from the master.
Well, it had been four days since i posted here. Still waiting for guidance from the master.
What is it you don’t understand?, what have you tried, just saying “is not working” doesn’t help me help you.
Questions are not like wine - they don’t improve by age.
“Doesn’t work” doesn’t work.
Hi,
how can i change maxNumberofFiles after initialization?
Let’s say i have a checkbox that’s allowing a visitor to upload more than one files if clicked.
So i might want to bing a behaviour to that checkbox that changes maxNumberofFiles to 1 or 7.
is this possible?
thanks,
alp
Please check the widget options, the option you need its.
maxNumberOfFiles
This option limits the number of files that are allowed to be uploaded using this widget.
By default, unlimited file uploads are allowed.
Type: number
Example: 10
Thanks!!!
Where will we include these option in xupload? in widget or in separate js code ?
i tried
<?php Yii::app()->clientScript->registerScript('script', <<<JS
$('#images-form').fileupload({
singleFileUploads: true
});
JS
, CClientScript::POS_READY);?>
in view and
<?php
$this->widget( 'xupload.XUpload', array(
'url' => Yii::app( )->createUrl( "/site/upload"),
//our XUploadForm
'model' => $photos,
//We set this for the widget to be able to target our own form
'htmlOptions' => array('id'=>'images-form'),
'attribute' => 'file',
//'multiple' => true,
'formView' => 'application.views.site._form',
'singleFileUploads' => true,
)
);
?>
Also tried ‘singleFileUploads’ in ‘htmlOptions’
but all not worked for me…
XUpload its a CJuiInputWidget, you use it and pass js options as you would with the options param
Worked !!!
Thank You very much Asgaroth…
Hey Asgaroth,
first let me thank you for the creation of this very useful extension!
After some trying around I managed to get everything working as expected apart from one feature: I can not validate the file type as done by others here in the thread or as described in the jQuery plugins docs.
My widget is called like this:
<?php
$this->widget('xupload.XUpload', array(
'url' => Yii::app()->createUrl('members/default/upload', array('id'=>$model->id)),
'model' => $upload,
'attribute' => 'file',
'multiple' => true,
'options' => array(
'maxFileSize'=>3000000,
'acceptFileTypes' => "/(\.|\/)(gif|jpe?g|png)$/i",
),
));
?>
The jQuery generated for xUpload is as follows:
jQuery('#XUploadForm-form').fileupload({'maxFileSize':3000000,'acceptFileTypes':'/(\\.|\\/)(gif|jpe?g|png)$/i','url':'/members/default/upload/id/26'});
However, attaching any file that should validate (or any other) results in the following error in my console:
Any ideas why that happens? I’m kind of stuck here . Once I delete the ‘acceptFileTypes’ line, everything works, just no validaiton of file types which is kind of important. Thanks in advance!
Best,
Philipp
Hi there, check this previous post, you should add js: to the string
Hello,
I have installed this ext and success to upload,
I’m followed this http://www.yiiframework.com/wiki/348/xupload-workflow/ to input value from another field to database
but i still not success with that…
My Submit button doesn’t work. anyone can help me?
Whats the problem? please elaborate so that we can help you
First problem solved, i directing the code in after save from the example to the main controller.
And now i got problem, becouse my form will upload 2 type of data
img -> for cover url
mp3 -> for music
xupload override all files form so i must do a validation before i save.
Hi Asgaroth,
I am having a couple of issues with the extension. One is that none of the styling at all appears. I looked at the source of my page and all the template code is in the source, but it does not appear to do anything. This is my lesser issue.
The main issue is that when I run it, the extension only uploads the last file selected, then outputs to the browser the following:
[{"name":"423e83apt3b-ktchn2.jpg","type":"image\/jpeg","size":125567,"url":"\/1grout\/07192012\/423e83apt3b-ktchn2.jpg","thumbnail_url":"\/1grout\/07192012\/423e83apt3b-ktchn2.jpg","delete_url":"\/moneyshot\/default\/upload\/_method\/delete\/file\/%2Fhome%2Fairmuse%2Fpublic_html%2Fprotected%2F..%2F1grout%2F07192012%2F423e83apt3b-ktchn2.jpg","delete_type":"POST"}]
My view file calls the widget as such:
<div id='uploadArea'>
<?php
$this->widget('xupload.XUpload', array(
'url' => Yii::app()->createUrl("moneyshot/default/upload"),
'model' => $model,
'attribute' => 'file',
'multiple' => true,
));
?>
</div><!-- uploadArea -->
In my default controller, I put the following:
public function actions()
{
return array(
'upload'=>array(
'class'=>'xupload.actions.XUploadAction',
'path' =>Yii::app() -> getBasePath() . "/../" . user()->id . "grout",
'publicPath' => Yii::app() -> getBaseUrl() . "/" . user()->id . "grout",
),
);
}
In XUpload.php I set multiple to true.
Thank you.
Can we restrict uploaded images according to width and height(640x480) ?
Hi there, the styling is not an issue, please read through the previos posts to see why. as for the other issue, which browser are you using, and have you tried other browsers? does the the javascript console outputs something?
I don’t think so, I don’t see a way to get those values on the client side. not sure about HTML5 though
Hi Asgaroth, thanks for the response. I figured out what was going on. I had used renderpartial to draw the upload form and needed to put processoutput=true. I have basic functionality established, and now just need to iron out all the kinks. Good extension.
I noticed this same thing in the logic, but isn’t the solution even easier?
if($this->subfolderVar)
…
elseif($this->subfolderVar!==false)
…
Whether subfolderVar is set to false, null or the empty string, the first condition will be false. Then the second condition will only be false if subfolderVar is specifically set to false.
Hi,
can we set subfolderVar from the widget code?
i mean like this:
$this->widget('xupload.XUpload', array(
'url' => Yii::app()->createUrl("machines/upload"),
'model' => $model2,
'attribute' => 'file',
'multiple' => true,
'options'=>array(
'maxNumberOfFiles' => 1,
'maxFileSize'=>3000000,
'subfolderVar'=>'01012012',
)
for me, this doesn’t work, it uploads to default dmY subfolder.
i really need to set the subfoldervar from the widget, is there a way to this?