473,383 Members | 1,877 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Uploading file from Database

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
Feb 28 '07 #1
3 1085
On Feb 28, 1:22 am, "tshad" <t...@home.comwrote:
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)

Feb 28 '07 #2
"tshad" <t@home.comwrote in message
news:uL**************@TK2MSFTNGP02.phx.gbl...
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";
Feb 28 '07 #3
Makes sense.

Thanks,

Tom
"Mark Rae" <ma**@markNOSPAMrae.comwrote in message
news:OS****************@TK2MSFTNGP03.phx.gbl...
"tshad" <t@home.comwrote in message
news:uL**************@TK2MSFTNGP02.phx.gbl...
>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";

Mar 1 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: John Smith | last post by:
I know that uploading an image to a database has been covered, oh, about 3 trillion times. However, I haven't found anything covering uploading to a MySQL database with .net. Please don't...
1
by: Gary | last post by:
Hi all, I am trying to upload file (>500 MB in size) from my webform. Bandwidth is not a issue as the asp.net application would be used in the Intranet environment. Can someone plz suggest...
0
by: TJ | last post by:
Hi, I've written code web-based uploading and downloading. Here is some code for it. For saving file into MS-SQL database, SaveFileIntoDB(HttpPostedFile file) { int fileLength =...
4
by: Himanshu | last post by:
hi, Can anybody tell me that thru asp.net using c#, how can we upload and download physical files in any table of SQL Server Database. the uploading part is running successfully but the...
1
by: needin4mation | last post by:
Hi, I am uploading a file and changing a record in a database. When the database is updated, I retrieve the last_insert_id() to get the latest row key. I also have a Page_Load event that...
3
by: Carlos | last post by:
Hello Forum, I would appreciate it if you could recommend settings to use auto-vacuum in my version 7.4 database. I am uploading several thousands records in the database at a rate of ~1 second...
5
by: Chris | last post by:
I have a meetings section I'm developing on our intranet. Using PHP/MySQL. Meeting info and Meeting docs reside on 2 related tables in the db. Users may want to upload anywhere from 1 to 10 or...
4
by: | last post by:
Can someone offer or point me to some sample code or advice on how to upload a document from a web page and store it into a SQL Server image field? And then reverse the process and serve up the file...
6
by: ajaykataram | last post by:
Hi all i am getting error in the following code to upload files csv and txt files i have to insert the following values only into database if firstname,lastname and email id is null it should not...
221
Atli
by: Atli | last post by:
You may be wondering why you would want to put your files “into” the database, rather than just onto the file-system. Well, most of the time, you wouldn’t. In situations where your PHP application...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.