File Download, Hyperlink, etc.

User input to define file and place location in link.

Page 1 of 1

3 Replies - 11790 Views - Last Post: 15 January 2008 - 12:35 PM Rate Topic: -----

#1 gymratz   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 129
  • Joined: 18-October 07

File Download, Hyperlink, etc.

Posted 11 January 2008 - 02:09 PM

My Intent:
To allow the user to browse for an item on the network and when the page is submitted to take this information and store it in a SQL database.
When the page is reloaded at a later date the information from the DB will populate a link that can be clicked to open this file.

How I currently have it done:
I am using the FileUpload control to allow the user to navigate to their file. When the page is saved I access the link by using the command file_Strategy_Desc.PostedFile.FileName

To display this link at a later date I am using the HyperLink control and accessing it using:
link_open_aa.NavigateUrl

Problem(s):
When a user is selecting a file and then submits the whole page to save, the page will error out if the file is too large. I am guessing that this "FileUpload" control is doing some background work where it is testing if it can copy the file to it's server. I don't want this as all I need to do is get the path to the file. Is there a better control to use or a way to prvent this?

Secondly the information saves properly in the database (for instance it will show C:\Documents and Settings\Rober\Desktop\Doc3.doc

However once displayed as a hyperlink it changes to
file:///C:/Documents%2520and%2520Settings/robert/Desktop/Doc3.doc

This link not only doesn't work if you copy/paste it into the address bar, when clicking on it nothing happens at all.


Any ideas on resolutions?

Thanks!

Is This A Good Question/Topic? 0
  • +

Replies To: File Download, Hyperlink, etc.

#2 gymratz   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 129
  • Joined: 18-October 07

Re: File Download, Hyperlink, etc.

Posted 14 January 2008 - 12:40 PM

So I have heard that you cannot have a link to a local file on the web (Such as S:\Temp) will not work and you must use a UNC path.
So I have changed my code such that the path given replaces the shared drive S:\ with the UNC path \\server\shared\
This works well in my situation because all files will be on the same share. This is not an ideal solution though and I wish it could be fixed.

Second and more pressing problem is not resolved.
I need to determine if there is a better way than using the "file Upload" control to allow the user to browse for a file so that I can take this path and use it. The file upload control is causing the page to take a long time to save because it is trying to load the file into memory. I have increased the max size from standard 4mb to 50mb so that I don't get the timeout any more - but there has to be a better way to do this!
Was This Post Helpful? 0
  • +
  • -

#3 alaub   User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 34
  • Joined: 08-January 08

Re: File Download, Hyperlink, etc.

Posted 14 January 2008 - 05:10 PM

View Postgymratz, on 14 Jan, 2008 - 12:40 PM, said:

Second and more pressing problem is not resolved.
I need to determine if there is a better way than using the "file Upload" control to allow the user to browse for a file so that I can take this path and use it. The file upload control is causing the page to take a long time to save because it is trying to load the file into memory. I have increased the max size from standard 4mb to 50mb so that I don't get the timeout any more - but there has to be a better way to do this!


well I don't know how to do it but wouldn't there be some way to instead of saving the file to the database just save the string of the file location...

...just a thought thrown wildly out
Was This Post Helpful? 0
  • +
  • -

#4 gymratz   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 129
  • Joined: 18-October 07

Re: File Download, Hyperlink, etc.

Posted 15 January 2008 - 12:35 PM

Sorry I didn't include my code, that is what I currently do.

When a button at the bottom of the page is clicked (edit_current_strategy) here is part of the code:

new_link_open_strategy_desc = file_Strategy_Desc.PostedFile.FileName
			new_link_open_strategy_desc = Replace(new_link_open_strategy_desc, "S:\", "\\umpqua\companies\shared\", 1, -1, 1)


So all I am grabbing is the path that is included in the FileUpload control, replacing the local drive with a UNC and saving it to a variable.

I do this many times as this is a large page with a lot of information to fill out. At the end of the page is a long and ugly SQL statement that inserts this variable into the SQL database. So if you look at the database all it has in a varchar(255) section is the path to the file.

For some reason though (and based on some google searching) this FileUpload control has a behavior where it loads the file into memory before doing any processing. So even though I do not have any code to "upload" the file anywhere - it still does this task.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1