Uploading file from Database

T

tshad

I have a file that I want to upload periodically from a users machine if
they come back later.

I am storing the filename and path in my database. But the HtmlInputFile
normally file is set to read-only.

For example, if I have the object:

<input id="MyResumeFile" style="width:300px" type="File" runat="Server">

If I get the filename from an earlier upload that I stored in my database as
such:

MyResumeFile.PostedFile.FileName = dbReader("UploadFileName")

I get the error:

Property 'FileName' is 'ReadOnly'

Is there a way to use the name stored in a database with the Upload File
object?

Thanks,

Tom
 
G

Guest

I have a file that I want to upload periodically from a users machine if
they come back later.

I am storing the filename and path in my database. But the HtmlInputFile
normally file is set to read-only.

For example, if I have the object:

<input id="MyResumeFile" style="width:300px" type="File" runat="Server">

If I get the filename from an earlier upload that I stored in my database as
such:

MyResumeFile.PostedFile.FileName = dbReader("UploadFileName")

I get the error:

Property 'FileName' is 'ReadOnly'

Is there a way to use the name stored in a database with the Upload File
object?

Thanks,

Tom

it's true - FileName is ReadOnly because it give your the source name

Use PostedFile.SaveAs to save the file with desired name

For example,

NewFileName = Server.MapPath("/resume/") & dbReader("UploadFileName")
MyResumeFile.PostedFile.SaveAs(NewFileName)
 
M

Mark Rae

MyResumeFile.PostedFile.FileName = dbReader("UploadFileName")

I get the error:

Property 'FileName' is 'ReadOnly'

That's right.
Is there a way to use the name stored in a database with the Upload File
object?

No, for (fairly obvious!) security reasons. Imagine the following on a
public website:

MyResumeFile.PostedFile.FileName = @"C:\...\...\Outlook.pst";
 
T

tshad

Makes sense.

Thanks,

Tom
Mark Rae said:
That's right.


No, for (fairly obvious!) security reasons. Imagine the following on a
public website:

MyResumeFile.PostedFile.FileName = @"C:\...\...\Outlook.pst";
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top