I need some help with customizing an upload.aspx. I have a VB.Net 2005 Winform that has a file picker and a textbox (plus loads of other stuff). When the user selects a file, I want to upload the file to a server.
This is the command I am using in my Winform to upload the file:
Separately, I've created an upload.aspx page that works fine. When I select a file or type a filename into the textbox on the upload.aspx page and click upload, the file is uploaded to the correct directory on the server.
The upload.aspx form is simple with just one textbox and 2 buttons:
Protected Sub btnUpload_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btn_Upload.Click Dim i As Integer Dim objFile As HttpPostedFile Dim strFileName As String Dim strMessage As String = ""
For i = 0 To Request.Files.Count - 1 objFile = Request.Files(i) If Len(objFile.FileName) > 0 Then strFileName objFile.FileName.Substring(objFile.FileName.LastInd exOf("\") + 1) Try objFile.SaveAs(Server.MapPath("~/Files") & "/" & strFileName) strMessage &= "<span>" & strFileName & " successfully uploaded</span><br/>" Catch ex As Exception strMessage &= "<span>Failed uploading " & strFileName & ": " & ex.ToString() & "</span><br/>" End Try End If Next i
txtMsg.InnerHtml = strMessage End Sub
So, how do I pass the filename to be uploaded to the upload.aspx page? (Something like http://server/upload.aspx?filename)??? I know the code that's in the button click event will work when someone actually clicks the button, but where do I put the code so that it'll fire when the winform tries to upload a file? (It seems that the page load event might be ok, but, is the page ever loaded?)
I don't want the Winform user to ever see the upload.aspx page. I just want the Winform UploadFile command to use the form to put the file on the server.
Any help would be greatly appreciated!!
Last Visit: 31-Dec-99 19:00 Last Update: 24-Feb-17 18:12