ASP Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreASP Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old September 16th, 2003, 08:35 AM
ahmekar ahmekar is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 32 ahmekar User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 30 m 10 sec
Reputation Power: 6
Question Browse files from input type=FILE?

I have a form. I need to get the pdf file from the server directory, put the complete URL to the input box and insert it into the DB table.

Code:
<INPUT TYPE='FILE' SIZE='40' NAME='FILE1'>"


When I clicked on the browse button, the file string appears like this --> \\server\Inetpub\Web\letters\file.pdf in the input box

The way I like it is
---> G:\Web\letters\file.pdf

then convert the string to "G:\Web\letters\file.pdf"
to -- http://www.website.com/letters/file.pdf

This URL will be placed on the web site for users to click on.

Reply With Quote
  #2  
Old September 16th, 2003, 09:05 AM
mrusaw's Avatar
mrusaw mrusaw is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Dallas, Texas
Posts: 138 mrusaw User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Send a message via AIM to mrusaw Send a message via Yahoo to mrusaw
The reason it comes back"\\server\file" is because you are probably accessing it through a network place or file share. If you map a drive to the location and then access it thorugh the network drive you will get the results you seek.

I would still recommend not relying on that technique and simply parse the string and reformat as necessary so that you handle both situations (network place or mapped drive)
__________________
mr...

mike.rusaw@realpage.com
RalPage, Inc.

"I have made this letter longer than usual, only because I have not had the time to make it shorter." - Blaise Paschal

Reply With Quote
  #3  
Old September 16th, 2003, 11:50 AM
ahmekar ahmekar is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 32 ahmekar User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 30 m 10 sec
Reputation Power: 6
Okay, you were right about map drive and network place location.

I agree this technique is not as good if the map drive letter changes.
from "G:\Web\letters\file.pdf"
to "H:\Web\letters\file.pdf"

But how could I parse the string from either network place or mapped drive since the strings are all different?

I want to limit only able to browse files from one mapped drive or network place.
-->G:\Web\letters\file.pdf
or
-->\\server\inetpub\Web\letters\file.pdf

(they are both in the same location, it just depends on how the file is browse)

Reply With Quote
  #4  
Old September 16th, 2003, 01:31 PM
mrusaw's Avatar
mrusaw mrusaw is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Dallas, Texas
Posts: 138 mrusaw User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Send a message via AIM to mrusaw Send a message via Yahoo to mrusaw
This is where the fun comes into play. They are different but there is some information that is common all the time. Forget about where they are different and find where they are the same. (i.e. they are all going to reside on "\Web\SomeDirectory...\SomeFile...". So you'll want to do the following:
1. parse the string looking for "web" and return everything to the end of the string
2. replace the "\" with "/"
3. apply the appropriate http info at the begining ("http://www.website/") then you have a complete new url that is dynamic based on the file which will be unique but the website url prefix always stays the same.

Reply With Quote
  #5  
Old September 16th, 2003, 01:50 PM
mrusaw's Avatar
mrusaw mrusaw is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Dallas, Texas
Posts: 138 mrusaw User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Send a message via AIM to mrusaw Send a message via Yahoo to mrusaw
Here is how i would parse the string. It should work for your example on what ever server you choose:

Code:
<INPUT TYPE='FILE' SIZE='40' NAME='mstrFile1'>"

Dim mstrFileURL
mstrFileURL= ("http://" & Request.ServerVariables("SERVER_NAME") & Replace(Mid(mstrFile1, InstrRev(mstrFile1, "Web") + 3), "\", "/"))


Let me know if that helps...

Reply With Quote
  #6  
Old September 16th, 2003, 03:02 PM
ahmekar ahmekar is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 32 ahmekar User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 30 m 10 sec
Reputation Power: 6
Would you explain what does the number 3 mean in your code? --is this the position of letters of the word "web"?

It's not working on mine, see following
Code:
<INPUT TYPE='FILE' SIZE='40' NAME='mstrFile1'> 
<% Dim mstrFileURL					
mstrFileURL= ("http://" & Request.ServerVariables("SERVER_NAME") & Replace(Mid(mstrFile1, InstrRev(mstrFile1, "abcde") + 5), "\", "/"))

From the code above, the string I got from the input box after selected the file is "H:\abcde\file.pdf", should I be seeing http://.......?

The Request.ServerVariables("SERVER_NAME") works fine. But I have a couple addresses on one server like
- web.sitename.com
- abcde.sitename.com (actual web site reside)

The form I have is in web.sitename.com
From the form, I only want to browse files in abcde.sitename.com, so the Request.ServerVariables("SERVER_NAME") will end up "http://web.sitename.com" instead of
"http://abcde.sitename.com"

Sorry, should have mentioned this earlier, I was trying not to confuse people. But thanks a lot for your effort here!

Reply With Quote
  #7  
Old September 16th, 2003, 03:10 PM
mrusaw's Avatar
mrusaw mrusaw is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Dallas, Texas
Posts: 138 mrusaw User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Send a message via AIM to mrusaw Send a message via Yahoo to mrusaw
I am getting the following output when i run:

Code:
Dim mstrFileURL  	
   	   Dim mstrFile1
   	   mstrFile1 = "H:\abcde\file.pdf"
   	   mstrFileURL= ("http://" & Request.ServerVariables("SERVER_NAME") & Replace(Mid(mstrFile1, InstrRev(mstrFile1, "abcde") + 5), "\", "/"))
   	   Response.Write(mstrFileURL)


output: http://localhost/file.pdf

Reply With Quote
  #8  
Old September 16th, 2003, 03:14 PM
mrusaw's Avatar
mrusaw mrusaw is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Dallas, Texas
Posts: 138 mrusaw User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Send a message via AIM to mrusaw Send a message via Yahoo to mrusaw
Also the InstrRev returns and integer of the location where the search string is located. The "+3 or +5" adds additional positions for determining what to return as a result. I assumed you did not want to return "Web" so I added 3 ( or 5 in the case of abcde).

Reply With Quote
  #9  
Old September 16th, 2003, 03:57 PM
ahmekar ahmekar is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 32 ahmekar User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 30 m 10 sec
Reputation Power: 6
Thanks very much! It works mr.

I moved the following code to another page and leaving this line
<INPUT TYPE='FILE' SIZE='40' NAME='mstrFile1'> on the first page

Code:
mstrFile1 = request.Form("mstrFile1")

mstrFileURL= ("http://" & Request.ServerVariables("SERVER_NAME") & Replace(Mid(mstrFile1, InstrRev(mstrFile1, "abcde") + 5), "\", "/"))

response.Write mstrFileURL	

Reply With Quote
  #10  
Old September 16th, 2003, 04:46 PM
mrusaw's Avatar
mrusaw mrusaw is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Dallas, Texas
Posts: 138 mrusaw User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Send a message via AIM to mrusaw Send a message via Yahoo to mrusaw
Great! I should have been more specific about the <input> tag. I just wanted you to see that you needed to rename the field (or at least make them match) and then you can intercept the requested form variable and since it is a module level string variable i name it "mstr" then "File1".

Good luck. I hope you can help someone else out in the future...

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreASP Programming > Browse files from input type=FILE?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT