473,569 Members | 2,839 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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="MyResumeFil e" style="width:30 0px" type="File" runat="Server">

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

MyResumeFile.Po stedFile.FileNa me = dbReader("Uploa dFileName")

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 1090
On Feb 28, 1:22 am, "tshad" <t...@home.comw rote:
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="MyResumeFil e" style="width:30 0px" type="File" runat="Server">

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

MyResumeFile.Po stedFile.FileNa me = dbReader("Uploa dFileName")

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.Save As to save the file with desired name

For example,

NewFileName = Server.MapPath( "/resume/") & dbReader("Uploa dFileName")
MyResumeFile.Po stedFile.SaveAs (NewFileName)

Feb 28 '07 #2
"tshad" <t@home.comwrot e in message
news:uL******** ******@TK2MSFTN GP02.phx.gbl...
MyResumeFile.Po stedFile.FileNa me = dbReader("Uploa dFileName")

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.Po stedFile.FileNa me = @"C:\...\...\Ou tlook.pst";
Feb 28 '07 #3
Makes sense.

Thanks,

Tom
"Mark Rae" <ma**@markNOSPA Mrae.comwrote in message
news:OS******** ********@TK2MSF TNGP03.phx.gbl. ..
"tshad" <t@home.comwrot e in message
news:uL******** ******@TK2MSFTN GP02.phx.gbl...
>MyResumeFile.P ostedFile.FileN ame = dbReader("Uploa dFileName")

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.Po stedFile.FileNa me = @"C:\...\...\Ou tlook.pst";

Mar 1 '07 #4

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

Similar topics

10
7382
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 recommend storing the image to the filesystem and only keeping a pointer to that in the table. I want to dump the image to a table. My code dumps the...
1
1060
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 any asynchronus way of inserting records into database from a dataset ?
0
1511
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 = file.ContentLength; byte fileContent = new byte; int lastPos = file.FileName.LastIndexOf('\\');
4
2145
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 problem arises in the retriving part of the code. i am not getting that how will i able to download the file which is there in the SQL Server database in...
1
1248
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 populates controls on the form. The Page_Load gets the information from the database, including the field that has the latest key from my database (say...
3
2347
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 per record (the data is uploading from a different server). I have noticed that the performance of the uploading is improved if I vacuum the...
5
2711
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 more documents to share/use during a meeting presentation. What would be the most efficient way to approach this? This is the logic I'm currently...
4
1659
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 from the database when requested through a web page... Thanks. Jerry
6
4090
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 accept the data and skip that row. And for csv file if encounters headings it should skip that row the fields are...
221
367158
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 needs to store entire files, the preferred method is to save the file onto the server’s file-system, and store the physical location of the file in...
0
7695
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7612
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8119
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7668
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7964
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6281
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3653
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3637
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2111
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.