473,769 Members | 5,205 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 2992
On 2003-11-09, Hunter Peress <hf*******@yaho o.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*******@yaho o.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*@doxd esk.com
http://www.doxdesk.com/
Jul 18 '05 #3
In article <ma************ *************** *********@pytho n.org>,
Hunter Peress <hf*******@yaho o.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*******@yaho o.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.FieldStorag e()

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

<html><head><ti tle>Testing</title></head>
<body>
<form enctype="multip art/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
5379
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 support this form of POSTs. There is support in cgi.py, for servers. There are some implementations of multipart/form-data on ASPN: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/146306 urllib2_file seems to meet my needs, but I'm not...
10
19358
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 able to fill that one out just fine. The second form is multipart/form-data. Unfortunately, I haven't been able to fill that out in a way that makes the server happy. I set up a copy of this form at my web site so that I could see exactly what a...
6
6105
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 parse the filename. <form name='form1' method='POST' enctype='multipart/form-data' action='sub.asp'> <input type='text' name='title1' value='value1'> <input type='file' name='file1'>
4
4580
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 forum). I don't use server controls in it (apart from Page). The problem occurs on the page where visitor can post a new messages. Basically, it's a form with couple of
7
17338
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 to get it to work in Visual Basic. I tried coding it once myself from scratch and then modified a class that I found on a newsgroup (referenced below). Both seem to be doing the same thing and neither works (or rather, they seem to work but the...
4
5897
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
3146
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 handle the upload? thanks.
1
4417
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 would give it a try. First of all, I am using Visual Studio 2005 to write my program. I am using C# .NET as the language. I am running Windows XP Professional with all service packs and updates applied. Now, I have been trying to write a...
3
6053
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 progress bar). Everything works great; except that currently I'm not decoding the POST in PERL; so the data file being written is the actual raw form data (multipart/form-data) with parameters and file content. I know that when you make a post to...
0
10222
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10050
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9999
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8876
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7413
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6675
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5310
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3967
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3570
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.