|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
|
#2
|
|||
|
|||
|
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. |
|
#3
|
|||
|
|||
|
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 ???? |
|
#4
|
||||
|
||||
|
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" |
|
#5
|
|||
|
|||
|
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.
![]() |
|
#6
|
|||
|
|||
|
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. |
![]() |
| Viewing: Dev Articles Community Forums > Programming > ASP Development > multiple file uploads dont work |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|