Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > WebClient Upload

Reply
Thread Tools

WebClient Upload

 
 
=?Utf-8?B?dmFzaW1v?=
Guest
Posts: n/a
 
      09-24-2007
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.



 
Reply With Quote
 
 
 
 
bruce barker
Guest
Posts: n/a
 
      09-24-2007
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)

vasimo wrote:
> 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.
>
>
>

 
Reply With Quote
 
 
 
 
=?Utf-8?B?dmFzaW1v?=
Guest
Posts: n/a
 
      09-25-2007
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


"bruce barker" wrote:

> 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)
>
> vasimo wrote:
> > 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.
> >
> >
> >

>

 
Reply With Quote
 
George Ter-Saakov
Guest
Posts: n/a
 
      09-25-2007
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.

"vasimo" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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.
>
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Webclient.upload + ftp + user select Fabrice ASP .Net 0 06-27-2009 02:14 PM
response from webclient.upload Stacey ASP .Net Web Services 0 04-12-2006 06:28 AM
File Upload issues with WebClient.UploadFile Phillip N Rounds ASP .Net 1 02-02-2006 09:13 PM
Upload a file without file Upload control - ASP.Net =?Utf-8?B?U2FyYXY=?= ASP .Net 3 08-03-2005 01:09 AM
WebClient Class / Upload File / IIS 405 Error Grant Harmeyer ASP .Net 4 09-08-2004 11:25 AM



Advertisments