[EXTENSION] FancyUpload

Well without log works but with a litle problem now: Arquivo enviado: (null x nullpx, null)

It says all this nulls… cant see with height nor mime. I dont use it on my app but i would like to know the problem i presume the mime its because the getMimeType(); but the with and height is very strange.

thanks for all your help scoob i hope i will help you improve this extension in the future.

its not a problem at all, this is done via javascript, in your view file:




file.info.set('html', '<strong>Arquivo enviado:</strong> (' + json.get('width') + ' x ' + json.get('height') + 'px, <em>' + json.get('mime') + '</em>)');



the information you’ve said is sent to the view by using the $return array in the controller, so it is read in the view in the callback javascript

to get the image size, in your controller you’ll have to load the file with GD library and set in the return array, like




//..use GD to get height and width...(this code you can find on Google)


//and add to the return array

$return = array(

                'status' => '1',

                'name' => $file->getName(),

                'height'=>$height,

                'width'=>$width,

                'mime'=>$mime

                    );



or you can only ignore this by overwiting the code in your view




'onFileSuccess'=> "function(file, response) {

                var json = new Hash(JSON.decode(response, true) || {});


                if (json.get('status') == '1') {

                        file.element.addClass('file-success');

                        file.info.set('html', '<strong>Success</strong>');  //note i changed this line

                } else {

                        file.element.addClass('file-failed');

                        file.info.set('html', '<strong>Error:</strong> (' + (json.get('error') ? (json.get('error') + ' #' + json.get('code')) : response));

                }

            }",



regards!!

:)

Ok. And how can i add for example an php action that is on the fancy controller, to an event for example remove file event.

Best regards.

well, it’s not a feature of fancyupload, so, please, take a look at the unlink() PHP function, it will certainly help you in doing this

usually I do this in my afterDelete event of my model so when the model related to the file is deleted, the file is automatically removed too

:)

regards!!

Yes but what i want to do is when you click "Remover" this go to remove the file from database and afterDelete the file will be unlinked. The problem is how to do when you click "Remover" how you do to tell javascript to delete the record or go to a action on the controller?

731

removefile.png

oops, it seems like we have a misunderstood … heeh, sorry :)

the button you’re talking about just remove the related file from the queue, it doesn’t perform any interaction with controllers or external links

the button i’m talking about is the one you have in your admin view or any other you create when showing the pictures

don’t really know if it is possible to change this behavior in fancyupload plugin and fancyupload official forum hasnt been helped me :(

if you figure out how to do this, please, share with us, i’m interested on this topic too, but with little time to play around it now

thanks

regards!

:)

scoob to do this i think we have to use the callback:




'onFileRemove'=>"function() {

    //ajax call to 'url'=>CController::createUrl('/fancy/DeleteRecord'),

}",



but i dont know how to call ajax on this example, do you know how to do it?

thanks

Koz, sorry for the delay…

well, fancyupload uses mootools js framework, so, i think that a simple ajax call made in mootools could help

I’ve found this http://davidwalsh.name/basic-ajax-requests-mootools, but, as I told you, have no time to test it now

hope it helps!

regards!

:)

Hi scoob now i put my files online on a linux server and it dont work… but in my local xamp it works fine… i’m getting HTTP-status 403… i’ve changed my code to be very simple and i still get this error can you help me please, here is the code:

Controller:




public function actionUploadedFiles() {

    session_id($_POST['PHPSESSID']);

    session_start();

    $return = array('status' => '1','name' =>'ZZZ','id_file' => 1,'mime_file' => 'image/jpeg','size'=>'192kb');

   echo json_encode($return) ;

}

Going to my controller url index.php/fancy/uploadedfiles it runs just fine and prints


{"status":"1","name":"ZZZ","id_file":1,"mime_file":"image\/jpeg","size":"192kb"}

I’v also attached my view file.

hey!

403 error is "Forbiden", maybe the target folder is not writeable by the webserver proccess, try changing permissions to 755 (or 777 - only for testing!!)

From fancyupload’s website:

Uploads fail with 406/403 error

From the swfupload documentation (it applies to all Flash scripts depending on FileReference):





    If you are using Apache with mod_security this will not work, you need to put the following in your .htaccess file to disable mod_security:





    SecFilterEngine Off SecFilterScanPOST Off





    Disabling mod_security isn’t allowed on some shared hosts, and only do this if you know what you are doing. This is due to a bug in the way that flash sends the headers back to the server according to the Flash 8 documentation

Uploads fail with 403/500 error

Check your server config, there must be something wrong. Also see 404, double check the upload URL.

hope it helps!!!

:)

regards!

I’m dont even trying to save the file just getting the json values… and i’m already putted that commands on htaccess and still not working :\

…let me ask you something…are you using some RBAC / srbac or filter rule in your controller?

could you please try removing the security control for testing? i think that flash isn’t retrieving the session so the action doesn’t get validated

it works when you call the url directly in your browser because the session is “alive”, it’s a php simple call

this is a problem in flash uploaders and i remember that i’ve seen a topic for this in the forum regarding another flash uploader extension…i will try to find the topic to send you

regards!!

koz,

here are some topics regarding security and flash uploaders

http://www.yiiframework.com/forum/index.php?/topic/9704-flash-requests-and-security/page__pid__47939__st__0&#entry47939

external

http://www.uploadify.com/forum/viewtopic.php?f=5&t=43

some workaround is needed to acomplish the task, but seems to work

please, let us know if some of these solves the problem

regards

Hey all,

I’m pretty new to FancyUpload, but have made some good progress and have run into a roadblock.

Initially my form was a few text fields that entered into a database. This worked perfectly, auto-increment id, name, description, and story.

I now want to add the option to upload photos, so I set up a standalone FancyUpload to learn how to use it. I have it working so it was just the form and it uploaded into the proper directory.

Next step was to merge the 2 forms onto the same page, text inputs first, image attachments second. It looks great, and the image upload works when I hit submit, but this is where it gets weird.

None of the information in the text inputs gets saved/added to the database, the images upload to the specified folder, but the weird thing is that for every image I upload a blank row is added into the database that I want the text to go. For example, if I upload 5 images, I get 5 blank rows in my DB.

In general, any advice how to add FancyUpload to another form? One with text inputs, and media attachments second?

Hey, alax89!

I’ve never used fancyupload inside the create form because there may have some cases when users upload some images and then cancel the new record saving, so i’d end up with images without a related record

i’d suggest two things:

1 - put the fancy upload in the view, right after the create/update

or

2 - put the code to only show fancyupload in update mode, I mean, after insert, redirect to update the same record

Personally, i’ve been using the former approach, but if someone has a better idea, suggestions will be very welcome!

:)

hope it helps

regards!!!

You’re talking about having a 2 step submission? I could do to that, but I’d rather make that a last resort – it’d be so much cleaner if it’s possible to have them on the same page. Perhaps something like what I’ve drawn up here. Is it possible to have a form in a form? Queue up the images with 1 button, then submit the whole thing with another?

790

awesomediagramform.JPG

yes, Yii supports nested forms

http://www.yiiframework.com/doc/guide/form.builder#creating-a-nested-form

if fancyupload is in the same form of text inputs, i think that you could try using the plugin’s callbacks to submit all the data

i’ve never tried this before due to time restrictions but if you make some progress, please, share with us

thanks

:)

regards!

I’m not using Yii and don’t know anything about it actually, I found this thread when I searched for my problem about FancyUpload. When I have more time I’ll take a look at it, thanks.

I’m still not using Yii, but here’s an update of what I have so far. I’m not sure why it isn’t working.

When the form page loads (submit.php) there are the 3 text boxes, and the FancyUpload script. When you click submit, the FancyUpload script runs first. I edited FancyUpload2.js so the onComplete() now includes the following code:


		document.forms.submit_form.action = "submit_script.php";

		document.forms.submit_form.submit();	

submit_script.php is the handler for the text part of the form. That changes the action of the form, and submits it. This works perfectly. The images upload, and the text gets added to the database.

The problem is that I need the id of the submitted information from the database to move the uploaded images into the proper folder (/uploads/<id>/).

To get around this, I changed submit.php to create 1 row when you load it, and added a hidden form field (name=‘submit_id’) that holds the value of the id of the new row. I also have it create a folder called /uploads/<submit_id> (ex. /uploads/653)

Now, submit_script.php updates the row WHERE id=’$submit_id’ ($submit_id = $_POST[‘submit_id’]) instead of creating a new row. This works fine.

Previously my uploads would all go to /uploads/, so I changed those lines (in server/script.php) to read:


move_uploaded_file($_FILES['Filedata']['tmp_name'], '../uploads/' . $Submit_Id . '/' . $_FILES['Filedata']['name']);

$return['src'] = '../uploads/' . $Submit_Id . '/' . $_FILES['Filedata']['name'];

$Submit_Id = $_POST[‘submit_id’] just like in submit_script.php, but this doesn’t work. The uploader still uploads to /uploads/ instead of /uploads/<id>

Any thoughts?

hey!

i think that $Submit_Id is null, try using $submit_id as you said that the WHERE clause works fine, case sensitive could be the problem here

regards!

:)