Toady Posted July 20, 2007 Share Posted July 20, 2007 (edited) This is a quick and fast way to upload files to another computer thats running IIS (Internet Information Services). I developed this tool for a project I am currently working on where I work. It works by doing these steps: On computer your wanting to upload files to, you will need to have a website directory in your "\wwwroot" directory. For this example I am using my own computer so the path to this directory is: c:\Inetpub\wwwroot\myWebsite\ I then place Upload.aspx in this directory, thereby making the URL to this page: http://localhost/myWebsite/Upload.aspx I then created a folder inside of "myWebsite" directory and named it "uploads", this is where I will be uploading my files. c:\Inetpub\wwwroot\myWebsite\uploads\ After this I made sure that the security settings on the "uploads" folder are set appropriately so I can get write access. I then run this AutoIt script to upload a file. It will allow the user to select a file to upload then upload the file. #cs ----------------------- ASP.NET File Upload Example ------------------------ Author: Toady Requirements: Upload.aspx on IIS web server Security permissions for Uploads folder need to be set accordingly #ce ---------------------------------------------------------------------------- #include <IE.au3> $IEo = _IECreate("http://localhost/myWebsite/Upload.aspx",0,0,1,0) $FileInput_obj = _IEGetObjByName($IEo,"FileInput") ; File input tag $uploadfileid_obj = _IEGetObjByName($IEo,"uploadfileid") ;Submit button $status_obj = _IEGetObjById($IEo,"status") ;Asp:label _IEAction ($FileInput_obj, "click") ;Click on Browse button _IEAction ($uploadfileid_obj, "click") ;Click on upload button ; A "choose file" window will display, select a file, then click ok SplashTextOn("Attempting to upload","Please wait...",200,30) _IELoadWait($IEo) ;wait for file to upload SplashOff() $status_obj = _IEGetObjById($IEo,"status") ;read label for status If _IEPropertyGet($status_obj,"innertext") = "Success" Then MsgBox(0,"","File Uploaded") Else MsgBox(0,"Upload Failed",_IEPropertyGet($status_obj,"innertext")) EndIf _IEQuit ($IEo) Exit Below is the asp page I wrote to handle the requests. There is no real error handling, this is just a working example. Hopefully this comes in use. It did for me! expandcollapse popup<%@ Page Language="VB" Strict="false" EnableViewState="false" %> <%@ import Namespace="System" %> <%@ import Namespace="System.IO" %> <%@ import Namespace="System.Web" %> <%@ import Namespace="System.Web.UI" %> <%@ import Namespace="System.Web.UI.WebControls" %> <script runat="server"> Public Dim rootDir As String 'rooDir is the location inside of \wwwroot\ to upload files Sub Page_Load() rootDir = Server.MapPath("\myWebsite\uploads\") Response.write(rootDir) End Sub ' AutoIt clicks the Upload File button Sub UploadFile(ByVal sender As System.Object,ByVal e As System.EventArgs) Dim UploadFileLocal = rootDir & Path.GetFileName(FileInput.PostedFile.FileName) Response.write(UploadFileLocal) Try FileInput.PostedFile.SaveAs(UploadFileLocal) status.Text = "Success" Catch Exc As Exception status.Text = Exc.Message End Try End Sub </script> <html> <form id="myform" method="post" enctype="multipart/form-data" runat="server"> <INPUT id=FileInput type=file runat="server"> <asp:button id=uploadfileid onclick=UploadFile runat="server" Text="Upload File" type="submit"> </asp:button> <asp:label id=status runat="server" Text="Ready"> </asp:label> </form> </html> Edited July 21, 2007 by Toady www.itoady.com A* (A-star) Searching Algorithm - A.I. Artificial Intelligence bot path finding Link to comment Share on other sites More sharing options...
Toady Posted July 21, 2007 Author Share Posted July 21, 2007 No comment? This is amazing, I use this at work and it helps me lots. www.itoady.com A* (A-star) Searching Algorithm - A.I. Artificial Intelligence bot path finding Link to comment Share on other sites More sharing options...
James Posted July 21, 2007 Share Posted July 21, 2007 Wow this is great! I am using it now Thanks again Toady, for the useful script you gave us Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
rbhkamal Posted July 23, 2007 Share Posted July 23, 2007 nice, I could really use this. Thanks for sharing "When the power of love overcomes the love of power, the world will know peace"-Jimi Hendrix Link to comment Share on other sites More sharing options...
Apzo Posted July 24, 2007 Share Posted July 24, 2007 I've done something similar, but with an apache server. The php part was just a basic upload form, the AU3 script call the URL, fills and submit that form. Due to file size limit (2M in my case), the script splits the file into 1.5M packets and sends them all, they are gathered by another php script later. Now I'm using apache/WebDav, file transfers are no more a probem Apzo. All the pop3 functions.Rsync your files on your USB key (or anywhere else) Link to comment Share on other sites More sharing options...
microsoft Posted August 1, 2007 Share Posted August 1, 2007 it's a good script Link to comment Share on other sites More sharing options...
NELyon Posted August 2, 2007 Share Posted August 2, 2007 It is good, but the same thing can be accomplished via Web-based Autoit Maybe it will be my next project. But this script is still very good Link to comment Share on other sites More sharing options...
Toady Posted August 2, 2007 Author Share Posted August 2, 2007 It is good, but the same thing can be accomplished via Web-based Autoit Maybe it will be my next project.But this script is still very good Thx for the comment, it may be accomplished in another way. Yet the title of this thread says "Asp & AutoIt".... catch my drift? www.itoady.com A* (A-star) Searching Algorithm - A.I. Artificial Intelligence bot path finding Link to comment Share on other sites More sharing options...
EvAsion Posted August 2, 2007 Share Posted August 2, 2007 Great script, now i just gotta learn ASP so i can make it only accept certain file types. |-- Periodic Table --||-- Dynamic Class Timetable --||-- Navigation in Counter-Strike --| Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now