Cgi File Upload without Form

Discussion in 'Python' started by Karsten.G.Weinert@googlemail.com, Apr 27, 2007.

  1. Guest

    Hello,

    what is the simplest way to upload a file (or a long string) to a
    server using cgi/python?

    Since I want to upload the data programmatically, a form based
    solution is not good. I am not experienced with SOAP/WSDL and I
    believe that would be more difficult than necessary. The client
    program I have to use does not support FTP.

    Any hint appreciated, kind regards,
    Karsten.
    , Apr 27, 2007
    #1
    1. Advertising

  2. En Fri, 27 Apr 2007 18:10:42 -0300, <>
    escribió:

    > what is the simplest way to upload a file (or a long string) to a
    > server using cgi/python?
    >
    > Since I want to upload the data programmatically, a form based
    > solution is not good. I am not experienced with SOAP/WSDL and I
    > believe that would be more difficult than necessary. The client
    > program I have to use does not support FTP.


    I don't understand your question. Do you control the server, the client,
    or both? Which one is in Python?

    --
    Gabriel Genellina
    Gabriel Genellina, Apr 28, 2007
    #2
    1. Advertising

  3. Max M Guest

    skrev:
    > Hello,
    >
    > what is the simplest way to upload a file (or a long string) to a
    > server using cgi/python?
    >
    > Since I want to upload the data programmatically, a form based
    > solution is not good. I am not experienced with SOAP/WSDL and I
    > believe that would be more difficult than necessary. The client
    > program I have to use does not support FTP.


    Try out urllib2

    --

    hilsen/regards Max M, Denmark

    http://www.mxm.dk/
    IT's Mad Science
    Max M, Apr 28, 2007
    #3
  4. Steve Holden Guest

    wrote:
    > Hello,
    >
    > what is the simplest way to upload a file (or a long string) to a
    > server using cgi/python?
    >
    > Since I want to upload the data programmatically, a form based
    > solution is not good. I am not experienced with SOAP/WSDL and I
    > believe that would be more difficult than necessary. The client
    > program I have to use does not support FTP.
    >

    A "form-based" solution is actually just what you want - you write a
    Python program that does just what the user's browser would do after
    they filled in a form.

    You can do this with urllib fairly easily. If you get stuck then look
    for a library called mechanise.

    regards
    Steve
    --
    Steve Holden +1 571 484 6266 +1 800 494 3119
    Holden Web LLC/Ltd http://www.holdenweb.com
    Skype: holdenweb http://del.icio.us/steve.holden
    ------------------ Asciimercial ---------------------
    Get Python in your .sig and on the web. Blog and lens
    holdenweb.blogspot.com squidoo.com/pythonology
    tag items: del.icio.us/steve.holden/python
    All these services currently offer free registration!
    -------------- Thank You for Reading ----------------
    Steve Holden, Apr 28, 2007
    #4
  5. Steve Holden Guest

    wrote:
    > Hello,
    >
    > what is the simplest way to upload a file (or a long string) to a
    > server using cgi/python?
    >
    > Since I want to upload the data programmatically, a form based
    > solution is not good. I am not experienced with SOAP/WSDL and I
    > believe that would be more difficult than necessary. The client
    > program I have to use does not support FTP.
    >

    A "form-based" solution is actually just what you want - you write a
    Python program that does just what the user's browser would do after
    they filled in a form.

    You can do this with urllib fairly easily. If you get stuck then look
    for a library called mechanise.

    regards
    Steve
    --
    Steve Holden +1 571 484 6266 +1 800 494 3119
    Holden Web LLC/Ltd http://www.holdenweb.com
    Skype: holdenweb http://del.icio.us/steve.holden
    ------------------ Asciimercial ---------------------
    Get Python in your .sig and on the web. Blog and lens
    holdenweb.blogspot.com squidoo.com/pythonology
    tag items: del.icio.us/steve.holden/python
    All these services currently offer free registration!
    -------------- Thank You for Reading ----------------
    Steve Holden, Apr 28, 2007
    #5
  6. Guest

    Thanks for your replies, however I think urlllib can not help me here.
    I have control over the server side (I can write a cgi-script in
    python), but I have very little control on the client side (I have to
    use VBA).

    Kind regards,
    Karsten.
    , Apr 30, 2007
    #6
  7. Dave Borne Guest

    > Since I want to upload the data programmatically, a form based
    > solution is not good.


    Karsten,
    Could you explain this statement? When I want to move data to a
    server in a CGI environment, a form post is the easiest way I can
    think of. What are the specific restrictions making forms a problem?

    -Dave
    Dave Borne, Apr 30, 2007
    #7
  8. Guest

    On 30 Apr., 15:51, "Dave Borne" <> wrote:
    > > Since I want to upload the data programmatically, a form based
    > > solution is not good.

    >
    > Karsten,
    > Could you explain this statement? When I want to move data to a
    > server in a CGI environment, a form post is the easiest way I can
    > think of. What are the specific restrictions making forms a problem?
    >
    > -Dave


    Hello Dave,
    what I was thinking was: a form post is meant to be used manually. But
    maybe I am wrong here and I can teach my VBA program to fill in forms
    automatically. If I were using python as client, I could fill in forms
    with urllib. However, I using python only server-side.

    Kind regards,
    Karsten.
    , Apr 30, 2007
    #8
  9. Guest

    OK, I think I have a simple solution now. I am going to use FTP in my
    VBA-Client (it's possible) and don't need to do any server-side
    programming.

    Kind regards,
    Karsten.
    , Apr 30, 2007
    #9
  10. Jarek Zgoda Guest

    napisa³(a):

    >> Could you explain this statement? When I want to move data to a
    >> server in a CGI environment, a form post is the easiest way I can
    >> think of. What are the specific restrictions making forms a problem?

    > what I was thinking was: a form post is meant to be used manually. But
    > maybe I am wrong here and I can teach my VBA program to fill in forms
    > automatically. If I were using python as client, I could fill in forms
    > with urllib. However, I using python only server-side.


    "Form" usually means an action accessible for HTTP POST request with
    content-type multipart/form-data. Uploading files is usually done in
    this way, if you don't want/cann't use more sophisticated means like
    WebDAV (which is HTTP extension, btw).

    --
    Jarek Zgoda
    http://jpa.berlios.de/
    Jarek Zgoda, Apr 30, 2007
    #10
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?U2FyYXY=?=

    Upload a file without file Upload control - ASP.Net

    =?Utf-8?B?U2FyYXY=?=, Aug 2, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    2,432
    Bruce Barker
    Aug 3, 2005
  2. Matt
    Replies:
    8
    Views:
    142,276
    zeeshanakhter2009
    May 26, 2012
  3. Replies:
    1
    Views:
    923
    Gabriel Genellina
    Nov 25, 2006
  4. Avin Patel
    Replies:
    4
    Views:
    935
    Brian McCauley
    Nov 5, 2004
  5. DJ Stunks
    Replies:
    1
    Views:
    178
    J. Gleixner
    Jan 23, 2006
Loading...

Share This Page