Re: Upload Files
Re: Upload Files
- Subject: Re: Upload Files
- From: Larry Mills-Gahl <email@hidden>
- Date: Sat, 20 Nov 2010 14:02:45 -0500
In playing with this a little more, I noticed one of the problems was
the AjaxFlexibleFileUpload is inside it's own form, so removing the
WOForm wrapping the WOFileUpload made that work really well (and the
auto upload worked well also)
I am going to look more into the AjaxFlexibleFileUpload because I'm
rethinking the process here a bit.
(Thanks for making me revisit this dormant project)
On 11/20/10 1:55 PM, Larry Mills-Gahl wrote:
> I spent a little time on this but it was a relatively low priority so I
> haven't finished. I could get a defined number of files uploaded without
> any problem, but I wanted to be able to allow the user to add more files
> to the upload batch. The problem was really a display problem because
> when I submitted the (ajax or component) action to add another slot for
> a file upload, the display of previous file names in the form would
> disappear. The information about those files was still in the component
> and ready to be uploaded, but for some reason, (my choice of bindings or
> something) made the form not display the filenames. As I said, this
> wasn't an urgent priority for me, so I let it sit (and it still sits).
>
> As I said, if you have a fixed number of file slots for upload when the
> component is created, this works fine. My problem came in when I added
> to the original file array. Here is what I did (in case anybody else has
> advice on the ability to add more slots for upload)
>
> It seems that AjaxFileUpload and AjaxFlexibleFileUpload focus on single
> file uploads so I worked with a basic WOFileUpload in order to get the
> core bits down. I haven't gotten back to trying to use either of these
> with multiple file uploads, so here is how I've done it up to now...
>
> I have a class called FileUploadMetadata which is just used to contain
> the information required to upload a file. That class contains the info
> to bind to the WOFileUpload.
>
> private String streamToFilePath ;
> private String finalFilePath;
> private String file2upload;
> private String description;
> private int bufferSize = 2000;
> private String overwrite = "true";
>
> The upload component contains a NSMutableArray<FileUploadMetadata>
> called files2Upload (ok, I know I'm inviting brain damage by calling the
> array files2Upload and the file inside the FileUploadMetadata
> file2Upload, but if I don't put the hard to find typo bugs in who
> will?... anyway...)
>
> The upload method just iterates through the files2Upload and creates a
> new file with the streamToFilePath
>
> The stripped down upload form is:
>
> <wo:WOForm enctype = "multipart/form-data" multipleSubmit = "true">
> <fieldset>
> <legend>Files:</legend>
> <wo:WORepetition list = "$filesToUpload" item = "$aFileMetadata">
> <wo:WOFileUpload streamToFilePath =
> "$aFileMetadata.streamToFilePath" finalFilePath =
> "$aFileMetadata.finalFilePath" overwrite = "$aFileMetadata.overwrite"
> bufferSize = "$aFileMetadata.bufferSize" filePath =
> "$aFileMetadata.file2upload" size = "60" />
> description: <wo:WOTextField value="$aFileMetadata.description" />
> <br />
> </wo:WORepetition>
> <wo:WOSubmitButton action = "$addFiles" value = "addAnotherFile" />
> </fieldset>
> <wo:WOSubmitButton action = "$upload" />
> </wo:WOForm>
>
>
> The addFiles action just adds another FileUploadMetadata to the
> files2Upload NSMutableArray.
> The upload action writes out some logging info for me to try to figure
> out why the display isn't what I expect, but the bulk of the work is
> just an iterator...
>
> ListIterator<FileUploadMetadata> it = filesToUpload.listIterator();
> while (it.hasNext()) {
> FileUploadMetadata fum = it.next();
> uploadInfoBuffer.append("\nfile " : " + fum.getFile2upload());
> if (fum.getFile2upload() != null &&
> fum.getFile2upload().length() > 0) {
> File upfile = new File(fum.getStreamToFilePath());
> }
>
> }
>
>
> On 11/19/10 10:17 AM, Frank Stock wrote:
>> Hi all,
>>
>> I need to upload several files at a time, what is the best way to do it: AjaxUpload or AjaxFlexibleUpload?
>> AjaxFlexibleFielUpload uses Adrew Valums routine, but it don't work like on the examples of valums website (there you can load several file at one time)
>> AjaxUpload uses jquery, can I use that so it works with the rest of ajax?
>>
>> Thank you form giving advice,
>> Frank Stock
>>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden