Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Feb 2006

    A application that can upload any kind of file to any hosting service

    The only way to upload files through my phone currently is by using Opera, but there's only 50% of chances a file is uploaded properly.It is crucial when uploading large files, cause after all the file is sent, there's the possibility to have only a message "Connection closed by remove server" and the file simply isn't sent.Due to this problem, i'm thinking of modifying a upload-script, so that it would allow me to upload any kind of file to any upload service, like tinypic.com , freeuploader.com and so on.Let's suppose i want to upload a file to a service whose page has the following html code:

    <form action="http://someuploader.com/upload.php" enctype="multipart/form-data" method="post">
    <input type="file" name="somefile">
    <input type="submit" value="host file">
    My network provides a internet connection through a proxy server, so the following module called urllibPROXY is needed.Thanks to nikhil_vaj for creating it for me.

    import urlparse
    import httplib
    import socket
    # Global variables that can be manipulated from the program
    # Similar to urllib.urlopen(...)
    def urlopen(url):
        global proxy_sock
        # Find the network location
        urlparts = urlparse.urlsplit(url)
        netloc = urlparts[1].split(':')
        host = netloc[0]
        port = 80
        if len(netloc) > 1:
            port = int(netloc[1])
        # Connect to the proxy
        proxy_sock=socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        proxy_sock.connect((proxy_host, proxy_port))
        # Create HTTP connection
        h=httplib.HTTPConnection(host, port)
        h.request('GET', url)
        r = h.getresponse()
        return r
    # Similar to urllib.urlretrieve(...)
    def urlretrieve(url, path):
        retval = 0
        body = r.read()
        # Save the response only if the response status is 200
        if r.status > 0:
            f = file(path, 'wb')
            retval = 1
            #print r.status, r.reason
            print r.status, r.reason
            retval = 0
        return retval
    # Closes the socket connection with the HTTP proxy server
    # Required since urlopen cannot close connection before 
    # response is read. [OPEN] Can this be avoided?
    def close():
        global proxy_sock
        if proxy_sock is not None:
            proxy_sock = None
    The script i want to modify is the following upload example by Jurgen Scheible:
    import httplib, urllib
    import appuifw
    import urllibPROXY
    def senddata():
        # read the file from the e drive and put it into a variable called xmlfile
        xmlfile = f.read()
        # define your parameters that shall be posted and assign its content: the parameter 'data' gets assigned the content of variable xmlfile   
        params = urllib.urlencode({'data': xmlfile, 'eggs': 0, 'bacon': 0})
        # define your headers
        headers = {"Content-type": "application/x-www-form-urlencoded",
                   "Accept": "text/plain"}
            # connect to the server: put here your server URL
            conn = httplib.HTTPConnection("someuploader.com")
            # make the post request to call the example.php file and handover the parameters and headers (put the correct folder structure here!)
            conn.request("POST", "/upload.php", params, headers)
            response = conn.getresponse()
            # close the connection
            appuifw.note(u"File was uploaded", "info")
            appuifw.note(u"something went wrong", "info")
    if appuifw.query(u"Upload file?","query") == True:
    I've already done some slight changes to this script.But i'm a beginner in Python language, hence i can't do everything i want.Some things i'm planning:

    1- Where it says


    , i'll change it to


    2- Right after it, there's a

    "Accept": "text/plain"

    Once my goal isn't to upload only texts, but any kind of file, i don't know what to put there.Does any one know?

    3- where it says


    i'll change it, in order to be able to enter the full path of the file i want to upload each time the application is launched.If i let it as it is, i have to change the script all the time to upload new files.Of course it would be better to have a file browser to choose the files more easily, but it's too much for me at the moment.

    I expect this uploader application to work this way:

    1- it asks the user to write the full path of the file that will be uploaded i.e e:\files\testfile.gif

    2-after confirming the file, you enter the server address i.e. someuploader.com

    3-Then the application asks for the complementar path after server address i.e. /upload.php?somefile=

    4-the upload begins.After the whole file is uploaded, a confirmation message appears i.e. Upload succesful

    5- the application downloads the same html page that would appear after the upload is complete if you were performing the operation using a normal web browser.This page would be saved to some path i.e. E:\temp\uploadtemp.htm , so that the user could open that page using some web browser, in order to get the link for the uploaded file.

    I don't know exactly what's better, modifying that example or creating a totally new one.But as a beginner, the first thing i thought was modifying a existing script.I've seen there're many people around here discussing about uploading stuffs.Please, let me know if you have some idea of how could i have this uploader working.

  2. #2
    Registered User
    Join Date
    Feb 2006

    Re: A application that can upload any kind of file to any hosting service

    I have a small tutorial page on s60 uploading (building from Mobilenin's examples) via HTTP Post Url Data, raw upload, and Multipart Form data.


    It might be what you need.


  3. #3
    Registered User
    Join Date
    Feb 2006

    Re: A application that can upload any kind of file to any hosting service

    Thanks, aymanshamma.I'll try your script right now and post the results here later.Does it loads the html page, saving it somewhere in phone/MMC memory, for the user to be able to get the link assigned to the uploaded file, i.e. in the case i want to upload a file in freeuploader.com , that gives a random name to the file, like 12236.zip instead the original name?

  4. #4
    Registered User
    Join Date
    Feb 2006

    Re: A application that can upload any kind of file to any hosting service

    I've just tested your script but here i only have a WAP gprs connection ( via proxy ) , then it didn't work, unfortunatelly.

Similar Threads

  1. Upload file from 6680
    By dlebot in forum Browsing and Mark-ups
    Replies: 2
    Last Post: 2005-07-14, 03:33
  2. Replies: 1
    Last Post: 2005-05-26, 14:22
  3. Replies: 0
    Last Post: 2002-06-10, 12:24
  4. How to Access 9210 Dbms file from my desktop application?
    By Nokia_Archive in forum Symbian Networking & Messaging (Closed)
    Replies: 0
    Last Post: 2002-06-03, 03:46

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts