Login  
Search All Forums
Dart Home | PowerTCP Web for ActiveX | Custom Development Reply | PowerTCP Web for ActiveX Topics | Forums   
AuthorForum: PowerTCP Web for ActiveX
Topic: Uploading files to an asp.net page
Salama

From: Portland, OR USA
Posts: 21
Member Since: 05/01/00
posted June 9, 2004 11:28 AM

I have an asp.net page which looks like this: It has just a file input field and a sibmit button.

<form id=AddPictureFromMail method=post runat="server"><input id=filePictureUpload type=file
name=filePictureUpload runat="server">
<input type="submit" id="btnSubmit" name="btnSubmit" value="Add Picture" runat="server" ><br></FORM>

It runs fine if I upload files interactively. When I used the multippartport sample to upload files programmatically, I get a "null object reference.." when I try to use filePictureUpload in my code.

I think I am missing something somewhere. Do I need to send a variable from the Multipart Post or change my asp.net program?

Thanks..

Salama
K M Drake



From: Utica, NY USA
Posts: 3406
Member Since: 07/14/00
posted June 9, 2004 1:01 PM

Hi Salama,
I don't know.
If it works when using IE, my advice would be to use a packet sniffer (for example, Ethereal) to see exactly what IE sends to the server, and then modify the Multipart Post sample so it sends the same exact message.
-ken
Salama

From: Portland, OR USA
Posts: 21
Member Since: 05/01/00
posted June 10, 2004 9:43 AM

Thanks. I will try a sniffer.

All I do is enter the url and the file in the multipart post program. Shouldn't there be a link between my page's file input field and what the post program sends. How does my page know what to do and what form's field is associated with the posted file?

Salama
K M Drake



From: Utica, NY USA
Posts: 3406
Member Since: 07/14/00
posted June 11, 2004 9:30 AM

Hi Salama,
I am not sure what you have to do on the server side to store the file. I use a third-party component to do this in an ASP page.

I can tell you what the Post message for uploading a file should look like. Below I have typical Post messages for both IE and the Multipart Post sample. There are some slight differences, but the structure of both messages are the same. As I stated earlier, if your server is able to store files when uploaded from IE, I would compare the two messages and modify the sample so that it sends the same message as IE.
-ken


IE POST Request:

POST /Upload.asp HTTP/1.1
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*
Accept-Language: en-us
Content-Type: multipart/form-data; boundary=---------------------------7d4e8490206
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.3705; .NET CLR 1.1.4322)
Host: myServer
Content-Length: 234
Connection: Keep-Alive
Cache-Control: no-cache

-----------------------------7d4e8490206
Content-Disposition: form-data; name="filename"; filename="c:\KDTest\myFile.log"
Content-Type: application/octet-stream

This is my file's data
-----------------------------7d4e8490206--


Sample POST request:

POST /Upload.asp HTTP/1.1
Accept: */*
Content-Type: multipart/form-data; boundary=---------------------------2240e9cd16d3c152
Content-Length: 245
User-Agent: Dart Communications PowerTCP
Host: myServer
Connection: Keep-Alive

-----------------------------2240e9cd16d3c152
Content-Disposition: form-data; name="myFile.log"; filename="c:\KDTest\myFile.log"
Content-Type: application/octet-steam

This is my file's data
-----------------------------2240e9cd16d3c152--
Salama

From: Portland, OR USA
Posts: 21
Member Since: 05/01/00
posted June 11, 2004 5:28 PM

I figured it out using a sniffer. I had to reference the input field in the 'name' field in post header instead of the actual filename which the post program puts.

Thanks!
K M Drake



From: Utica, NY USA
Posts: 3406
Member Since: 07/14/00
posted June 14, 2004 8:49 AM

Hi,
Ok, thanks for posting your solution,
-ken
Reply | PowerTCP Web for ActiveX Topics | Forums   
This site is powered by PowerTCP WebServer Tool PowerTCP WebServer for ActiveX