ASP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingASP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old June 25th, 2003, 05:16 AM
slfrudd slfrudd is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Location: Bradford , UK
Posts: 13 slfrudd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Unhappy multiple file uploads dont work

I have a picture gallery page, which has upload facilitys on it......

I can get uploads one by one by using a file upload control- works fine.

What i am trying to do is use a listbox that will collect the path and filenames of images residing on the clients PC ie C drive, then click the upload botton to copy all the listboxes items to the server in the appropriate directory.

Here is my code

Code:
For Each item In uploadlist.Items
                    expath = Server.MapPath(foldername)
                    expath += Path.GetFileName(item.Text)
                    Dim path1 As String = "file://" & item.Text
                    Dim path2 As String = expath
                    Dim fi As FileInfo = New FileInfo(path1)
                    Dim fi2 As FileInfo = New FileInfo(path2)
                    Try
                        fi.CopyTo(path2)
                    Catch ex As Exception
                        epgmsg.Text = ex.ToString
                    End Try
                    epgmsg.Text += Path.GetFileName(path2.ToString) & " uploaded"
                Next


What happens is IIS throws an error saying that URI formats are not supported.

I think the problem lies in the fact I am tryijng to copy from a client machine which has its own drive mappings to a server which has physical drive mappings as well (like d:\webspace)

If I leave out the file:// bit when defining the path1 string, the error returns that the path is not found......ie the c:\drive does not exist on the server!

Anyone know how to get round this problem ????

Cheers

Reply With Quote
  #2  
Old June 25th, 2003, 01:05 PM
digitallysmooth digitallysmooth is offline
you know how we do
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jun 2002
Posts: 788 digitallysmooth User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 34 m 21 sec
Reputation Power: 7
Just a guess, but try changing "file://" to "\\" and if that doesn't work try "\\\"
__________________
__________________________________________________ _
Wil Moore III, MCP | Integrations Specialist | Senior Consultant
Are You Listed...? | DigitallySmooth Inc.

Reply With Quote
  #3  
Old June 26th, 2003, 03:00 AM
slfrudd slfrudd is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Location: Bradford , UK
Posts: 13 slfrudd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
multiple file uploads dont work

I have tried every variation of the file://......but still no joy....

I presume that if the error states that URI is not supported, then it will never do it !

Is there some other way of copy files from a client directory to a server directory programmatically ????

Reply With Quote
  #4  
Old June 27th, 2003, 02:14 AM
stumpy's Avatar
stumpy stumpy is offline
May contain nuts.
Dev Articles Regular (2000 - 2499 posts)
 
Join Date: Aug 2002
Location: Sydney, AU
Posts: 2,058 stumpy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 8 m 57 sec
Reputation Power: 9
Send a message via ICQ to stumpy Send a message via MSN to stumpy
You can't just copy a file from a client to a server using the same file path.

You will need to specify on the server exactly where you want the file. By default (i.e. if u don't define it), the file will be copied to where the script is currently running from.

Also, you cannot use URI's, as you have found. You must use Absolute file paths. e.g. "c:\webfiles\docs\foo.doc"
__________________
DevArticles Moderator
BlueSix - Web Development and Consulting

Reply With Quote
  #5  
Old June 27th, 2003, 04:20 AM
digitallysmooth digitallysmooth is offline
you know how we do
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jun 2002
Posts: 788 digitallysmooth User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 34 m 21 sec
Reputation Power: 7
Good job stumpy... too bad I didn't really catch what he was trying to do there. Your explaination should help him better understand how to figure this out.


Reply With Quote
  #6  
Old June 27th, 2003, 08:10 AM
slfrudd slfrudd is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Location: Bradford , UK
Posts: 13 slfrudd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
multiple file uploads dont work

This is the code that I get from the trace of my page, the trace shows the two parameters that are passed into the File.Copy(source,destination)


Code:
C:\Documents and Settings\frudd_s\My Documents\My Pictures\spirit front.jpg 

D:\webspace\slfrudd.co.uk\wwwroot\pictures\Main\sp  irit front.jpg 


Both of them are well formed absolute paths...

But the error I get now is that the first file cannot be found shown here....
Code:
System.IO.FileNotFoundException: Could not find file "C:\Documents and Settings\frudd_s\My Documents\My Pictures\spirit front.jpg".
 File name: "C:\Documents and Settings\frudd_s\My Documents\My Pictures\spirit front.jpg" 
at System.IO.__Error.WinIOError(Int32 errorCode, String str) at System.IO.File.InternalCopy(String sourceFileName, String destFileName, Boolean overwrite) at 
My_Internet_Site.index5.btnupload_Click(Object sender, EventArgs e)spirit front.jpg uploaded


How do I specify that the file is residing on the clients hard drive....what are the drive mappings as seen from the server.....obviously all my web files are stored in a physical drive that is mapped as d:\webspace\slfrudd.co.uk etc etc

But what about the ones on the CLIENT machine. I think that is the real problem.

Scott.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingASP Development > multiple file uploads dont work


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 1 hosted by Hostway
Stay green...Green IT