• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: WOFileUpload in 5.2 and no file selected
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: WOFileUpload in 5.2 and no file selected


  • Subject: Re: WOFileUpload in 5.2 and no file selected
  • From: Hsu <email@hidden>
  • Date: Wed, 12 Mar 2003 21:51:03 -0800

Currently, the best way is to set the name attribute on the FileUpload component, and do a test in the submit action:

if ( (context().request().stringFormValueForKey("thefile.filename").equals("t hefile")) && (aFileContents.length() == 0) ) {
System.out.println("This is an empty file upload");
}



For interacting directly with MPI, you may need to do a length check in the write


int read = 0;
byte[] buffer = new byte[1024 * 1024]; // 1MB buffer
read = wfdIs.read(buffer);
if (read == 0) {
	if (aFileName.equals("thefile")) {
		System.out.println("This is an empty file upload");
	}
} else if (read != -1) {
	fileOutputStream.write(buffer, 0, read);
	do {
		read = wfdIs.read(buffer);
		if (read != -1) {
			fileOutputStream.write(buffer, 0, read);
		} else {
			break;
		}
	} while (read != -1);
}

None of this code is tested - it's off the top of my head.

Karl

On Tuesday, March 11, 2003, at 02:49  PM, Alf Martin Jensen wrote:

How can I test for "no file selected" in WOFileUpload element?

In WebObjects 5.1.x I used a test for an empty filePath returned, but in 5.2 I either get an exception before the action associated with the submit button is invoked (Safari) or the path is set to the name of the element (MSIE). All this on Mac OS X 10.2.4.

I've tried the FileUpload example from Apple and the behavior is the same.

Any ideas on or pointers to a workaround would be most welcome.

-- Alf Martin

--
Alf Martin Jensen mailto:email@hidden
Semafor Software ANS, http://www.semafor.no/amj
Grorudveien 16A, Tel: +47 22 25 38 32
N-0962 Oslo, Norway Fax: +47 22 16 12 02
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.



--

Cytosine, adenine, guanine, thymine

Homepage:
     http://homepage.mac.com/khsu/index.html
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >WOFileUpload in 5.2 and no file selected (From: Alf Martin Jensen <email@hidden>)

  • Prev by Date: Re: WebObjects and Java 1.4.1
  • Next by Date: Newbie: Non-direct to Java Application
  • Previous by thread: WOFileUpload in 5.2 and no file selected
  • Next by thread: Now that MacOS X Java 1.4.1 is out...
  • Index(es):
    • Date
    • Thread