[Extension] Xupload

Hi,

I have this extension up and running on a form with additional data + files.

So I’m submitting the form at the end after uploads (using ‘autoUpload’ => true).

I was wondering is there a way to disable the submit button and when (at least one of the) uploads are complete enable the submit button again? To prevent the user from submitting the form before the uploads are complete.




$this->widget('bootstrap.widgets.TbButton', array(

                'buttonType' => 'submit',

                'type' => 'primary',

                'disabled' => false, //This is what i want to change from true->false when uploads are done

                'label' => 'Submit',

            ));



I’ve tried to find a solution for some time now. If someone could point me to the right direction.

Thanks in advance!

Hi!

awesome extension!

I would like however, to use it for uploading TXT files and to use data from the TXT files. is it possible somehow to fill form fields with uploaded file’s content? That would be awesome!

Thanks a lot!

best regards,

c

can somebody point me to the right direction please, thanks.

I guess you have to allow the .txt extension file when you call to xupload, once the file is uploaded you will need to open it and read the content, the format file in which you will find your fields depends of your design, all this is up to you.

Saludos.

thanks a lot!

but I can’t find any relevant files with rules restricted only to upload image files. where can I find these rules?

I tried to print_r uploaded file, but I always get the error: "Invalid token T" or "Invalid token C" or "Invalid token X". What is this? Why is that?

many thanks

with this option you can restrict to upload only image files, so you will have to change the image extensions to the extension you desire:


'acceptFileTypes' => "js:/(\.|\/)(jpe?g|png)$/i",

Check the documentation here

Saludos

hi, thanks,

if there is no defined file type, it should accept any kind of files, right? there is no definition anywhere as I see.

this is what I can find in XUploadForm.php:


    public function rules() {

        return array(

            array('file', 'file'),

        );

    }



how can I check if the upload was successful? in fact, I don’t really need the file to be uploaded onto the hard drive, it’s fair enough for me to just temporarily upload it into memory, and extract it’s contents and persist into database. I would like to know at which step is the file available to use it. that’s what I don’t know yet. I wanted to try to print_r its contents, that’s when I got the error messages. can you please help me at which step is the file available to handle its contents?

strange, anyway upload seems good, but SAVE button is doing nothing.

thanks a lot!

I’m not sure if when you get the instance you are able to open and read the content, try to open and read the content file after:


$model->file = CUploadedFile::getInstance( $model, 'file' );

If you get some error, I guess you will need to save it in harddisk firstly, open and read the content file and after that delete the existing file.

What did you mean "SAVE button is doing nothing"?

I have tried this but maybe I was doing it wrong, I don’t know, isn’t is possible here to make a


print_r($model->file);

? I get “SyntaxError: Unexpected token” error. isn’t it an array? echo also give me “SyntaxError: Unexpected token” error.

you are right! but I still have no clue how to do it… :( I’m just struggleing.

thanks a lot

if I hit the submit or save button, nothing happens.

update! I have found some mistakes:

  • in chrome, firebug light doesn’t show error, in FF, FB show the error. the tmp folder was missing, that’s why there was no real upload! it began to save tmp files on my hard drive’s root…

now with print_r I see file contents in firebug (but why only in FB, why not on the page?), but it’s strange looking, and I get this error

I’m not sure if I really need this fancy ajax thing. now I could make it with the most simple way, and now it’s a good start for me.

Hi!

awesome extension!

would be possible to get the number of files uploaded correctly to establish a minimum number of files to validate the form?

Thanks a lot!

best regards,

another sol as the original example did:

just add this js to your view( the view where you add this widget)




<script type="text/javascript">

    $(function () {

        'use strict';


        // Initialize the jQuery File Upload widget:

        $('#XUploadForm-form').fileupload({

            url: 'getphotos/'

        });


        $.ajax({

            url: $('#XUploadForm-form').fileupload('option', 'url'),

            dataType: 'json',

            context: $('#XUploadForm-form')[0]

        }).done(function (result) {

            $(this).fileupload('option', 'done')

                    .call(this, null, {result: result});

        });

    });

</script>



and create an action like actionGetphotos as above url specified, the action collect the images data, and response json content as the download view expected.

that’s all.

Anyone?

Hi Asgaroth,

when uploaded the proportion height > width image , why the Preview images is transverse?

please help ,thanks so much!

Hello,

I need a list of all available callback functions ex:

$this->widget(‘xupload.XUpload’, array(

‘url’ => Yii::app()->createUrl(“form/upload”, array(“parent_id” => 1)),

‘model’ => $photos,//An instance of our model

‘attribute’ => ‘file’,

‘multiple’ => false,

‘options’ => array(//Additional javascript options

[color="#FF0000"][b]//I need all callbacks functions

‘onComplete’ => ‘’, …[/b][/color]

),

));

Thank You.

Xupload is based on jQuery File Upload plugin. You may find callbacks in the source or at the plugin docs.

Anyone has a Xupload version running the latest jQuery File Upload? I tried simply replacing the JS files found on the jQuery File Upload github but it doesn’t seem to work.

Thank you very much “Yugene” :)

Hi, Asgaroth!

First, thanks for the great plugin!

Second, my question:

If after upload files (but before save model data) i’ll reload page, for example, by F5 button, all generated images preview, disappear.

I want display their again, after page refresh.

What to do in this case?

Thx for your answer!

Is it possible to dispay already uploaded files when page loaded/reloaded, like in jQuery File Upload. If not, maybe you have some advice how to make it?

Same question