Skip to Content
author's profile photo Former Member
Former Member

Problem with FileUpload component

Hello all,

I'm using a FileUpload component and can't figure why I'm having this problem.

I have a button on the iView that calls this method when clicked.

<code>

public void onUpload(Event event)throws PageException{

__FileUpload fu = (FileUpload)this.getComponentByName("myFileUpload");

__if(fu!=null){

____IFileParam fileParam = fu.getFile();

____if(fileParam!=null){

______File f = fileParam.getFile();

______if(f!=null){

________uploadResource(f);

______}else

________myDDM.setStatus("Could not create File object");

____}else

______myDDM.setStatus("Could not create IFileParam object");

__}else

____myDDM.setStatus("Could not create FileUpload object");

}// End Method onUpload

</code>

I click said button after first 'Browsing' with the FileUpload component and selecting a file. When I check the status that has been set it is "Could not create IFileParam object" every time, which means that

<code>

IFileParam fileParam = fu.getFile();

</code>

returns NULL every time. Why would it do this after I've selected a file using the 'Browse' button of the FileUpload component.

Any ideas? The Javadoc for FileUpload is somewhat lacking. I see that there is a setAccept method which receives a String for mime type; but the API says that it isn't required.

I previously had this working as a JSPDynPage but strangely each time I previewed after deploying the .par file I got the old familiar "Dispatcher running, but no server connected" message. I'd wait 10 minutes, the server would be back up, I'd preview again and it would work. Strange. Now I'm using a DynPage and just coding the UI in Java, deploying doesn't knock the server over anymore but neither will it upload files.

As always, your help is well appreciated.

Patrick.

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Dec 30, 2004 at 08:12 AM

    Ahhh, I needed the line

    <code>

    myForm.setEncodingType("multipart/form-data");

    </code>

    I should read more!

    Shame I can't reward myself the points 😉

    Patrick.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.