jQuery-File-Upload icon indicating copy to clipboard operation
jQuery-File-Upload copied to clipboard

Call a php file after a successfull upload

Open gfr1991 opened this issue 14 years ago • 11 comments

Hi, I want to call a PHP script file after a successfull upload, but WITHOUT show it. This file I want to use contain instruction to send me an email when somebody upload a file on my server, so I think (is it right?) is enough to call him after the upload, but I don't know how to do this. Maybe I've to modify my jquery.fileupload.ui.js but I don't want to make wrong things, so if somebody have the code to insert... please help me :)

gfr1991 avatar Jul 20 '12 10:07 gfr1991

Nobody? Please I need help :(

gfr1991 avatar Jul 22 '12 09:07 gfr1991

Just handle this on the server side, there is no need to modify the javascript, just send the mail after the server received the file.

nexeck avatar Jul 22 '12 09:07 nexeck

How to do it? Would you be so kind and explain me how? Sorry for the bad english :)

gfr1991 avatar Jul 22 '12 09:07 gfr1991

http://php.net/manual/en/function.mail.php Just read the upload handler class and modify it.

nexeck avatar Jul 22 '12 09:07 nexeck

Thank you for your answer, but I need to carry on some infos about the uploader that are in the uploading page. So I think this solution doesn't perfectly fit my needs, although would be easier. So I'm back to the first question: is there a way to call a php file "silently" (without show it to the uploader) after a succesfull upload? :)

gfr1991 avatar Jul 22 '12 09:07 gfr1991

Just read the Docu... https://github.com/blueimp/jQuery-File-Upload/wiki/How-to-submit-additional-Form-Data https://github.com/blueimp/jQuery-File-Upload/wiki/API <- Programmatic file upload

Just trigger sending the mail within the success callback.

nexeck avatar Jul 22 '12 11:07 nexeck

And i think you should close this, because it is not an issue...

nexeck avatar Jul 22 '12 11:07 nexeck

I don't really want to close it. I know it's not an issue, but a request of explainations. And I still can't figure it out... Sorry for my poor skills in developing, but if someone would be so patience with me to explain step by step how to implement the code... 'cause I've struggled to insert some lines in *.js files, but I don't really know how to invoke a php files from javascript. I've this code: done: function (e, data) {
var that = $(this).data('fileupload'), template; if (data.context) { data.context.each(function (index) { var file = ($.isArray(data.result) && data.result[index]) || {error: 'emptyResult'}; if (file.error) { that._adjustMaxNumberOfFiles(1); } that._transition($(this)).done( function () { var node = $(this); template = that._renderDownload([file]) .css('height', node.height()) .replaceAll(node); that._forceReflow(template); that._transition(template).done( function () { data.context = $(this); that._trigger('completed', e, data);
} ); } ); }); } else { template = that._renderDownload(data.result) .appendTo(that.options.filesContainer); that._forceReflow(template); that._transition(template).done( function () { data.context = $(this); that._trigger('completed', e, data); } ); } },

And I don't really know where to put the request for my php file and HOW to write it. If you or someone else would be so kindful to explain me step by step I would be very grateful, otherwise I can't solve by myself. Sorry.

gfr1991 avatar Jul 22 '12 13:07 gfr1991

I just pointed you the correct direction. There is no need to modify the jquery file upload js file...

Just trigger an ajax call to your email sending php script within the success callback...

nexeck avatar Jul 22 '12 16:07 nexeck

Thank you nexeck, but that's the top spot: I don't know how to code it and where to insert that code I don't know how to write. Would you be so kindful to write me a sample code? If so, this will be my second-last post, I swear: the last would be a thanksgiving message for you :) :D :D

gfr1991 avatar Jul 22 '12 19:07 gfr1991

Please read: https://github.com/blueimp/jQuery-File-Upload#support

blueimp avatar Sep 05 '12 11:09 blueimp