Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / September 2007

Tip: Looking for answers? Try searching our database.

WebClient Upload

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
vasimo - 24 Sep 2007 16:46 GMT
Have the following code:
wkLocalPath = "C:\A\1.jpg"
wkServerPath = "http://servername/dirname/1.jpg"
wcClient.Credentials = New NetworkCredential("UID", "PW")
wcClient.UploadFile(wkServerPath, "PUT", wkLocalPath)

File exists on C.
Dir exist on server (ASPNET user and Admin user have full rights) (tried both)
Created virtual for Dirname and gave it write access in properties)
"POST" gives same results.

with or without credentials, throws: (404) Not Found
It looks like a security permissions thing. Just can't figure out what.
Someone thought it was a bug in Webclient since 1.0

Webclient download works fine.
Don't have a web page to put a file or Upload control on. Need to pull data
from client machine on the fly through inline code. Trying to create a DLL as
a service mod to do upload/Download from server.

Any help would be appreciated.
bruce barker - 24 Sep 2007 17:18 GMT
the serverpath needs to be a url that supports a fileupload post, not
where to write the file. the error is because an image does not suppport
a post.

if you want to access a webserver as a filesystem, look at webdav.

-- bruce (sqlwork.com)

> Have the following code:
> wkLocalPath = "C:\A\1.jpg"
[quoted text clipped - 17 lines]
>
> Any help would be appreciated.
vasimo - 25 Sep 2007 14:30 GMT
Thanks for your reply.
I'm a little confused (as always).
What do you mean by "the serverpath needs to be a url that supports a
fileupload post, not where to write the file"? Everything I read indicates
that the file name to create is appended to the back of the URL. I created a
virtual dir for the physical path and gave it write access.
I tried a POST as a last resort. I was under the impression that the POST is
for text data only. I am using a PUT which I thought handled all data streams.
I thought the 404(not found) was actually a security error not an
operational problem. Do you think I wrong in that assumption?
Thanks Vic

> the serverpath needs to be a url that supports a fileupload post, not
> where to write the file. the error is because an image does not suppport
[quoted text clipped - 25 lines]
> >
> > Any help would be appreciated.
George Ter-Saakov - 25 Sep 2007 20:38 GMT
The method PUT must be supported on a server. So server in response to
method PUT need to get the file and save it to proper folder.

By default (if you did nit do anything special) IIS does not support method
PUT. At least I believe so.

but you will have much better chances of getting it to work if you create
your onw uploadfile.aspx that accempt uploaded file

sample from MSDN:

MyUpload.aspx
<%@ Import Namespace="System"%>
<%@ Import Namespace="System.IO"%>
<%@ Import Namespace="System.Net"%>
<%@ Import NameSpace="System.Web"%>

<Script language="C#" runat=server>
void Page_Load(object sender, EventArgs e) {

   foreach(string f in Request.Files.AllKeys) {
       HttpPostedFile file = Request.Files[f];
       file.SaveAs("c:\\inetpub\\test\\UploadedFiles\\" + file.FileName);
   }
}

Code to upload file
myWebClient.UploadFile("http://myserver/MyUpload.aspx", "POST",
"filename.jpg");

George.

> Have the following code:
> wkLocalPath = "C:\A\1.jpg"
[quoted text clipped - 20 lines]
>
> Any help would be appreciated.

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.