Fog Creek Software
Discussion Board




Welcome! and rules

Joel on Software

automated file upload

Is it possible to automate login to a site and upload a file ( input type=file ) ? ,
I tried using xmlhttp for login , went through but when i tried to automate the upload stuff , i was redirected to the login page , I assume xmlhttp did not pass the session data .
Any clues on how this can be done ?.

benoy narayanan
Wednesday, December 15, 2004

We 'wrote' a tiny (100-line or so) FTP client (basically) that does this. Since we got 99% of it off the web (MSDN I think), I'd send it to you, if FTP'ing from some remote site to your .NET box is what you meant.

There are of course tons of commercial .NET FTP clients that would do a much more thorough job, but our thing is OK for our simple case (going out to a bunch of Unix boxes on the LAN and dragging a small text file across).

NetFreak
Thursday, December 16, 2004

Oops , sorry my question was not about 'ftp' ,
I needed to login to an existing website where i need to upload a file ( input type=file tags ) ,
There are users who login to the site and upload a file from a predefined location routinely , this chore needs to be automated  and once again this a website aka http protocol

benoy narayanan
Friday, December 17, 2004

How do you want to automate?
By using a vbs ? exe application?

Rochana
Monday, December 20, 2004

Could be anything which works !!!.

benoy narayanan
Thursday, December 23, 2004

I tried automating using a small vb app. It sits on 1 server and checks for files and if found it uploads them to another server. This is run as a job on SQL Server at a predetermined time.
At the recieving end an ASP page takes the multipart content request and passes that to AspSmartUpload component to decode and write the files.

I think you can get more info from this
http://www.Planet-Source-Code.com/vb/scripts/ShowCode.asp?txtCodeId=55649&lngWId=1

Rochana
Thursday, December 23, 2004

You could try using System.Net.WebClient, I believe it handles the cookies required to maintain a session.  If not, you would have to make use of the Cookies property of the HttpWebResponse object returned from the first call to set it in the next request.

To perform the upload, there's an UploadFile method on the WebClient object.

Jacob O'Reilly
Monday, January 03, 2005

*  Recent Topics

*  Fog Creek Home