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

FileUpload dont recognize getFile() method

Hi all,

I am trying to use a FileUpload component for a KM upload. After importing the external libraries (like ones from com.sap.netweaver.bc.util, com.sap.netweaver.bc.rf) some errors are still there at the following lines:

FileUpload fileUpload = (FileUpload)this.getComponentByName("myfileupload");

IFileParam fileParam = fileUpload.getFile();

if(fileParam != null)

{

this.mimetype = fileUpload.getFile().getContentType();

this.resource = fileUpload.getFile().getFileName();

..

}

The errors are:

"Cannot cast from Component to FileUpload"

"the method getFile() is undefined for the type FileUpload."

So it does not recognize the method getFile() of the class FileUpload.

I guess the problem is that some more libraries have to be added, but which ones i dont know so far

I have tried with both AbstractPortalComponent and JSPDynPage, but not working anyhow.

Can someone helps me, it took all my day trying to find out.

Best regards,

Raluca.

Add a comment
10|10000 characters needed characters exceeded

Related questions

2 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Feb 18, 2005 at 07:33 AM

    Hi Raluca.

    You are probalbly refering to the wrong FileUpload class! Check your import statements, they should include the following: "import com.sapportals.htmlb.FileUpload;".

    A common mistake is to include the following: "import com.sapportals.htmlb.unifiedrendering.controls.FileUpload;"

    Hope that helps.

    /Fredrik

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Feb 18, 2005 at 06:07 PM

    Hi Fredrik,

    your advise with import lead me to the right cause of error. The problem was the name of my defined class.

    Thanks,

    Best regards.

    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.