Quantcast
Channel: West Wind Message Board Messages
Viewing all articles
Browse latest Browse all 10393

Re: oHTTP.HTTPGet post file to FreeASPUpload page?

$
0
0
Re: oHTTP.HTTPGet post file to FreeASPUpload page?
West Wind Internet Protocols
Re: oHTTP.HTTPGet post file to FreeASPUpload page?
Nov. 30, 2012
07:45 pm
3NN16CLERShow this entire thread in new window
Gratar Image based on email address
From:Michael Hogan
To:Rick Strahl
No errors generated but the posted file does not end up in the upload directory BUT if I just manually browse to the page using the 'Choose File' and 'Upload File' buttons, the selected file DOES get properly uploaded. I think that rules out a permissions problem.

I tried adding R/W/L permissions to the upload directory for the NETWORK SERVICE, which is the listed identity for the Application Pool for the site, but no immediate change - perhaps I'll try rebooting - seems permissions changes don't always take effect immediately.

I'll also try your C# example, and prepend the destination directory to the HttpPostedFile upload =

Where is this failing and what is the error?
You may not have rights to write the file into that folder...

this works for me:

DO wwHttp loHttp = CREATEOBJECT("wwHttp") loHttp.nHttpPostMode = 2 loHttp.AddPostKey("MyFile","c:\sailbig.jpg",.T.) lcHtml = loHttp.HttpGet("http://localhost/wconnect/UploadTest.aspx") ? lcHtml

To this ASPX.cs page:

using

using System;using System.Collections.Generic;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;publicpartialclass UploadTest : System.Web.UI.Page {protectedvoid Page_Load(object sender, EventArgs e) { Response.Write(Request.Files.Count);foreach (string file in Request.Files.AllKeys) { HttpPostedFile upload = Request.Files[file]; Response.Write(" Length: " + upload.ContentLength.ToString()); Response.Write(" FileName: " + upload.FileName); }foreach (string formKey in Request.Form.AllKeys) { Response.Write(formKey + ": " + Request.Form[formKey] + "<hr/>"); } Response.End(); } }


This spits out 1 file and the filename.

+++ Rick ---



I now have a simplified ASP.NET form... The form works interactively but I'm still not getting the VFP HTTPGet to post the file:

<%@ Page Language="VB" %><script runat="server">Sub SubmitButton_Click(Source AsObject, e As EventArgs)IfNot (File1.PostedFile IsNothing) ThenTry File1.PostedFile.SaveAs("D:\Web\Chamberware\Www\Uploads\uploadedfile.txt") Span1.InnerHtml = "Upload Successful!"Catch ex As Exception Span1.InnerHtml = "Error saving file <b>C:\\"& _ File1.Value &"</b><br>"& ex.ToString()EndTryEndIfEndSub</script><html><head></head><body><form runat="server" enctype="multipart/form-data">Select a fileto upload:<br /><<span class="keywords">input type="file" id="File1" runat="Server"><p><<span class="keywords">input type="submit" id="Submit1" runat="Server" value="Upload File" OnServerClick="SubmitButton_Click"><p><span id="Span1" runat="Server" /></form></body></html>


I'm trying to automate posting a file to an FreeASPUpload page, but it's returning result: "Error in parsing uploaded binary request."

I'm using very simple code:

oHTTP = createObject("wwHTTP") oHTTP.nHttpPostMode = 2 && Multipart form encoding oHTTP.AddPostKey() && Clear existing POST buffer*** Post a file and a regular form variable oHttp.AddPostKey("attach1","c:\install.log",.T.) lcHTML = oHTTP.HTTPGet("http://www.chamberware.com/uploadTester.asp")STRTOFILE(lcHTML,"ReturnedHTML.HTM",0)

Looking at the ASP source code, it appears to be triggered by this ASP VB InstrB function:

PrivateFunction SkipToken(sToken, nStart) SkipToken = InstrB(nStart, VarArrayBinRequest, sToken)If SkipToken = 0 then...

Now... this particular upload tool requires some FORM elements are set for the code to work, but I don't know how to duplicate that in my HTTPGet call:
<code>
The following attributes of the FORM element are required and must have these exact values:

method="POST"
enctype="multipart/form-data"
accept-charset="utf-8"<</CODE>>

Any suggestions would be gratefully accepted...





Viewing all articles
Browse latest Browse all 10393

Trending Articles