• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 158
  • Last Modified:

Upload file

Hello,
    I have created a application in VB .NET to upload a file to a server. I am using file field from the HTML components in my application. I am using plumtree portal to upload my code. My problem is that the file field doesnt work in plumtree, by that I mean that after selecting a file in the file field the value is not captured. It returns null value. But if I run the same code on local machine everything work fine. I would like to know is there another way selecting a file if I am not using the file field.

Regards,
Rahul
0
rahulnimje
Asked:
rahulnimje
  • 2
  • 2
1 Solution
 
ayha1999Commented:
Hi,

I think it is better to use file field and you cannot capture it from remote machine like this
 Dim saveLocation As String
    Dim fn As String
    Dim filePosted As HttpPostedFile
    Dim fullPath As String

                fn = Path.GetFileName(YourfileFieldName.PostedFile.FileName)
                saveLocation = Server.MapPath("./YouFolder") & "/" & fn
                fullPath = "./Images" & "/" & fn     <---- you save this to db.
                filePosted = YourfileFieldName.PostedFile
                YourfileFieldName.PostedFile.SaveAs(saveLocation)

hope this helps.

ayha
0
 
rahulnimjeAuthor Commented:
That's the whole issue
when I write
 fn = Path.GetFileName(YourfileFieldName.PostedFile.FileName)

the value in fn is NULL

0
 
ayha1999Commented:
HI,

culd u pls. explain the problem?

ayha
0
 
rahulnimjeAuthor Commented:
I tried to run the code on local machine and it works fine. I am using a plumtree portal to make the application available to the users. After I upload the file on plumtree portal everthing goes fine except that it gives an error

"NULL Reference"

It is not able to capture the value from the file field.
I tried writing the way you told but still didnt help.

Regards,
Rahul
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now