473,508 Members | 2,226 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

truly working multipart uploads.

I have been unable to write a script that can do (and receieve) a multipart form upload.

Also, it seems that there really are differences between python's implementation and else's.

Can someone please prove me wrong with a script that works with itself AND with example 18-2
from php: http://www.php.net/manual/en/features.file-upload.php

__________________________________
Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard
http://antispam.yahoo.com/whatsnewfree

Jul 18 '05 #1
4 2977
On 2003-11-09, Hunter Peress <hf*******@yahoo.com> wrote:
I have been unable to write a script that can do (and receieve) a multipart form upload.

Also, it seems that there really are differences between python's implementation and else's.

Can someone please prove me wrong with a script that works with itself AND with example 18-2
from php: http://www.php.net/manual/en/features.file-upload.php


I have seen some discussions related to this question recently
on the python web-sig mailing list:
http://mail.python.org/pipermail/web-sig/

Jul 18 '05 #2
Hunter Peress <hf*******@yahoo.com> wrote:
Also, it seems that there really are differences between python's
implementation and else's.


Why do you say that? I know of no problems with receiving file uploads
fields in either the standard cgi module or my own replacement for it;
if you are talking about *sending* multipart/form-data requests, what
software are you using to create them?

The main 'gotcha' with sending and receiving form-data is that with
Windows, stdin and stdout are not by default binary streams, so could
corrupt newline characters if they are in the file, causing parsing
problems. If you are using Windows, ensure you have binary streams
(eg. with python -u).

--
Andrew Clover
mailto:an*@doxdesk.com
http://www.doxdesk.com/
Jul 18 '05 #3
In article <ma************************************@python.org >,
Hunter Peress <hf*******@yahoo.com> wrote:
I have been unable to write a script that can do (and receieve) a
multipart form upload.

Jul 18 '05 #4
Hunter Peress <hf*******@yahoo.com> wrote:
I have been unable to write a script that can do (and receieve) a multipart form upload.

Also, it seems that there really are differences between python's implementation and else's.

Can someone please prove me wrong with a script that works with itself AND with example 18-2
from php: http://www.php.net/manual/en/features.file-upload.php


Plop this script into a CGI directory somewhere, load it into your browser
and do the upload. Use a text file; it echos the file back out to your
browser. This uses the exact form from the php.net web page.
#! /usr/local/bin/python

import os
import cgi

q = cgi.FieldStorage()

if not q.has_key('userfile'):
print """\
Content-Type: text/html

<html><head><title>Testing</title></head>
<body>
<form enctype="multipart/form-data" action="x.py" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="30000">
Send this file: <input name="userfile" type="file">
<input type="submit" value="Send File">
</form>
</body>
</html>"""

else:
f1 = q['userfile'].filename
if q['userfile'].file:
contents = q['userfile'].file.read()
else:
contents = q['userfile'].value

print "Content-Type: text/plain"
print
print "Filename = ", f1
print "Here's the content:"
print contents

--
- Tim Roberts, ti**@probo.com
Providenza & Boekelheide, Inc.
Jul 18 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
5352
by: Nelson Minar | last post by:
I'm writing some code to upload photos to Flickr. The Photo Upload API requires documents be POSTed via a multipart/form-data request. I was surprised to learn that Python 2.3's HTTP clients don't...
10
19308
by: Gregory A Greenman | last post by:
I'm trying to write a program in vb.net to automate filling out a series of forms on a website. There are three forms I need to fill out in sequence. The first one is urlencoded. My program is...
6
6058
by: nate | last post by:
Hello, Does anyone know where I can find an ASP server side script written in JavaScript to parse text fields from a form method='POST' using enctype='multipart/form-data'? I'd also like it to...
4
4562
by: Alex Sibilev | last post by:
Hello, I have a really weird problem I've been trying to solve it without any luck for the last couple of hours :( I'm writing a "conference board" application (quite similar to ASP.NET...
7
17258
by: Mark Waser | last post by:
Hi all, I'm trying to post multipart/form-data to a web page but seem to have run into a wall. I'm familiar with RFC 1867 and have done this before (with AOLServer and Tcl) but just can't seem...
4
5879
by: Jim Michaels | last post by:
after a file upload, $_FILES is not populated but $_POST is. what's going on here? $_POST=C $_POST=C $_POST=C $_POST=C:\\www\\jimm\\images\\bg1.jpg $_FILES= $_FILES= $_FILES=
4
3131
by: pbd22 | last post by:
hi. could somebody tell me, when uploading a file, i know the form where the upload component is must have enctype=multipart/form-data but, is the same true for the form with the server code to...
1
4402
by: WeCi2i | last post by:
Okay, I have a problem that has been stumping me for weeks. I have tried many different solutions and this is pretty much my last resort. I have seen a lot of good answers give here so I figured I...
3
6036
by: jeremy.gehring | last post by:
Hey all, OK I'm not much of a PHP programmer; but needs must as they say. I have written AJAX file upload system that uses a PERL CGI script so that a PHP script can get the progress (nifty...
0
7123
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7326
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7383
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7046
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7498
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5627
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5053
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4707
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3194
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.