[Seaside] Multiple file upload with jquery ajax and FormData

Robert Sirois watchlala at hotmail.com
Sat Feb 23 02:45:40 UTC 2013


Is that JavaScript on a static page or is it generated by Seaside? I would suggest writing your jQuery with the Seaside package. That way, you can just call a method on your WAComponent and receive the data that way.
http://demo.seaside.st/javascript/jquery
RS

> Date: Fri, 22 Feb 2013 09:28:31 -0800
> From: unseokyeo at gmail.com
> To: seaside at lists.squeakfoundation.org
> Subject: [Seaside] Multiple file upload with jquery ajax and FormData
> 
> Hi Smalltalkers,
> 
> I am an absolute newbie to smalltalk (and seaside) in need of your great
> wisdom on file upload.
> 
> What I am trying to do is allow users to drag a file (or files) from their
> desktop and drop it to a <div> tag to trigger file upload.  I have it
> working with php but not sure how to translate this to *smalltalk way*.
> 
> On the browser side I am doing the following using javascript (and jquery):
> 1. preventDefault() on both 'dragover' and 'drop' to prevent browser from
> opening the file on drag and drop.
> 2. append each file to FormData :
> 
>    for (filename in filelist) {
>       formData.append(filename, filelist[filename]);
>     }
> 
> 3. Then fire an ajax call with formData:
> 
> 	$.ajax({
> 		*url: 'php/fileupload.php'*,
> 		data: formData,
> 		processDate: false,
> 		contentType: false,
> 		type: 'POST',
> 		success: function(data) {
> 			alert("File upload completed");
> 			removeAll();
> 		},
> 		error: function(a, b, c) {
> 			alert("Error: " + c);
> 		}
> 	});
> 
> But, I am lost when it comes to target url (in red) for this ajax request.
> 
> On the server side, I have a simple php that handles the request:
> 
> <?php
>     foreach ($_FILES as $filename => $file) {
>       if ($_FILES[$filename]["error"] > 0) {
>         echo "Error: " . $_FILES[$filename]["error"];
>       } else {
>         move_uploaded_file($_FILES[$filename]["tmp_name"], "upload/" .
> $_FILES[$filename]["name"]);
>       }
>     }
> ?>
> 
> Your help will be greatly appreciated.
> 
> 
> 
> Un-Seok
> 
> 
> 
> --
> View this message in context: http://forum.world.st/Multiple-file-upload-with-jquery-ajax-and-FormData-tp4671533.html
> Sent from the Seaside General mailing list archive at Nabble.com.
> _______________________________________________
> seaside mailing list
> seaside at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/seaside/attachments/20130222/7016798b/attachment.htm


More information about the seaside mailing list