Shop OBEX P1 Docs P2 Docs Learn Events
HTTP File Upload Demo — Parallax Forums

HTTP File Upload Demo

Mike GMike G Posts: 2,702
edited 2011-07-11 05:47 in Accessories
Here's the demo.
http://spinneret.servebeer.com:5000/upload.htm

Some rules:
Please make sure you use 8.3 file names. I have some validation.
File size is limited to around 740 byte text files. I know... but this is just a demo.

Try dropping a simple html file.

Edit: to see the file in the uploads directory, click the Get Files link in http://spinneret.servebeer.com:5000/uploads/index.htm. Time for a beer!
«1

Comments

  • LtechLtech Posts: 380
    edited 2011-06-06 14:00
    I can't see my uploads I try some.....

    BELGIUM.TXT
    BELGIUM.HTM 376bytes

    I can see from others:

    INDEX.HTM
    HPOST.TXT
    LUCIE.TXT
    HELLO.HTM
  • Mike GMike G Posts: 2,702
    edited 2011-06-06 14:33
    Did you click the browse button, select a file, then click submit? What browser are you using?
  • Mike GMike G Posts: 2,702
    edited 2011-06-06 18:29
    Made slight changes for Safari and Chrome. Give it another try.
  • LtechLtech Posts: 380
    edited 2011-06-07 00:19
    Mike G wrote: »
    Did you click the browse button, select a file, then click submit? What browser are you using?

    Yes, Yes,Yes ....
    Safari 5.0.5 (in osx 10.5.8 PPC)

    And No it still not work .....
    I can select file on my desktop, and do submit .... but nothing on index.
  • Mike GMike G Posts: 2,702
    edited 2011-06-07 09:19
    I tested the upload in Safari, Chrome, IE, FireFox, and Opera all on a PC though. I don't have a MAC. Anyway, I turned the logger on so all requests are captured. Any MAC folks that can give it shot?
  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2011-06-15 12:10
    worked fine with Firefox 4.X, but not with Chrome.

    OBC
  • Mike GMike G Posts: 2,702
    edited 2011-06-15 13:00
    You're welcome OBC :)

    My first reaction, "Gosh darnit [well, something like that] are you kidding me!, really!" Well, I gota' click the VIRUS.HTM see what's it's all about.

    I'll check the log and see if I can see what's up with Chrome. I thought I tested Chrome a few weeks ago and it is was working.
  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2011-06-15 13:44
    What are the chances that your code to be expanded to say 32k upload? This way you could upload a fresh binary, initiate a reboot and have the unit boot new "firmware" from the SD card? Naturally, you'd want to setup some sort of limited access to this ability. ;)

    OBC
  • Mike GMike G Posts: 2,702
    edited 2011-06-15 14:44
    I just need to uncomment a loop in the upload handler.
  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2011-06-15 15:00
    Have you posted your code for this anywhere yet? I'd like to add the functionality to my propellerpowered code.

    OBC
  • Mike GMike G Posts: 2,702
    edited 2011-06-15 17:18
    Have you posted your code for this anywhere yet?
    I'm sorry OBC, it's not published. I try to be very open with my code but I'm in a weird spot. I added new functionality that breaks the old code. I'm shooting for this weekend.
  • LtechLtech Posts: 380
    edited 2011-06-16 00:07
    Don't work for me OSX 10.5.8 PPC Safari 5.0.5
    Dutch language ....

    Is there somebody also use a non english os ?

    When y try to upload, the response is " No file selected" but when I select my file , it appears on the window.
  • Mike GMike G Posts: 2,702
    edited 2011-06-16 05:02
    Ltech; you should see "No file selected" after submitting.

    My upload code is not picking up the Content-Type: multipart/form-data; boundary= header or there's some kind of formatting that I'm not handling. I seems to be MAC/Safari related. A friend of mine was able to submit a file via FireFox on a MAC but not Safari. I can submit a file using Safari on a PC. I don't have a MAC so it's a little hard to troubleshoot. Anyway, I'm not seeing a log entry for the MAC stuff. So, I set the logger to append any time it sees an "upload" request regardless of the method.
  • Mike GMike G Posts: 2,702
    edited 2011-06-17 20:51
    Ltech, I think the bug is fixed... Please give file upload another try.
  • LtechLtech Posts: 380
    edited 2011-06-18 02:02
    No ! still not

    Sorry it is just for you debuging, not waist your time ....
  • Mike GMike G Posts: 2,702
    edited 2011-06-18 07:55
    I can see the POST request but there's no body.
  • Mike GMike G Posts: 2,702
    edited 2011-06-19 10:10
    Well, I uncommented the upload loop and there where problems. Imagine that... So I spent yesterday troubleshooting and was able to get ASCII files going. The largest file tested was around 110K. It takes a while to upload 110K, around 1 minute.

    I'm having problems with the binary upload. Honestly, I don't feel like messing with this anymore this weekend. OBC, I hope you don't mind waiting a little longer.

    http://spinneret.servebeer.com:5000/upload.htm
  • LtechLtech Posts: 380
    edited 2011-06-20 00:10
    YES upload works on MAC !

    :-)
  • Mike GMike G Posts: 2,702
    edited 2011-06-20 06:19
    Ltech, thanks for testing!

    Spinneret programmers, the MAC (osx 10.5.5 ppc Safari 5.0.5) sends the initial POST request with out body data. You must continue to read the input stream until the body byte count equals the content-length header value. I was thrown off because every browser I tested on a PC contained body data in the initial POST request.
  • jazzedjazzed Posts: 11,803
    edited 2011-06-22 12:01
    Mike.

    Can you make a variation of your program that would boot another Propeller from a downloaded file via a Spinneret serial port?

    Thanks.
    --Steve
  • Mike GMike G Posts: 2,702
    edited 2011-06-22 12:15
    Like this?

    1) Upload a binary to the Spinneret remotely. 2) Shot the uploaded binary to a second Propeller via a serial connection. 3) Load the binary and reboot the second Propeller.
  • jazzedjazzed Posts: 11,803
    edited 2011-06-22 17:10
    Mike G wrote: »
    Like this?

    1) Upload a binary to the Spinneret remotely. 2) Shot the uploaded binary to a second Propeller via a serial connection. 3) Load the binary and reboot the second Propeller.

    Something like that. I was thinking upload to the server, which downloads to the target Propeller using serial port and start it up. Writing to EEPROM is probably not necessary but may be useful for some. Later we may want to just put it on the SDcard in a predetermined place, release control of the SDcard, and then yank the target's reset pin briefly.
  • Mike GMike G Posts: 2,702
    edited 2011-06-22 17:17
    Jazzed, still a little fuzzy on the details
    which downloads to the target Propeller using serial port and start it up
    Are we talking about the Spinneret and a separate Propeller or the Propeller on the Spinneret board? What's downloaded to the target? What is the end result?

    I just finished testing a binary upload console application so I can save a Propeller binary or eeprom file on the Spinneret for firmware updates. It has rudimentary authentication and file integrity checking.
  • jazzedjazzed Posts: 11,803
    edited 2011-06-22 20:19
    Mike G wrote: »
    Are we talking about the Spinneret and a separate Propeller or the Propeller on the Spinneret board?
    Yes Spinneret and a separate Propeller. The end result is the separate Propeller should run the program saved to the SDcard.

    Chip posted a Spin program for loading a propeller from a propeller here:
    http://forums.parallax.com/showthread.php?86311-Propeller-Loader&p=591445&viewfull=1#post591445
  • Mike GMike G Posts: 2,702
    edited 2011-06-23 05:09
    Got it! I'm a little dense at times.

    I'll get working on it.
  • Mike GMike G Posts: 2,702
    edited 2011-06-25 20:56
    Geez Chip's code is elegant.

    I can load a program that fits in run-time memory. I'm not sure about a full blown 32K.
  • Mike GMike G Posts: 2,702
    edited 2011-06-26 09:56
    Got it working! We can upload a binary to the SD card then load that binary another Propeller.
  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2011-06-28 08:01
    Very cool!

    OBC
  • Daniel HarrisDaniel Harris Posts: 207
    edited 2011-07-11 02:16
    Hey Mike G.,

    That's pretty sweet that you can get the Spinneret to boot another Propeller from a binary on the SD card :). I could totally see the applications of loading specialized images for different situations.

    If you wanted, you could also use Kwabena's SD Card object to boot a binary off the SD card into the Spinneret's Propeller (even a full 32KB image). Check the method "PUB bootPartition(filePathName)" in his "S35390A_SD-MMC_FATEngine.spin" object. You can get it out of the zip file here:

    http://www.parallaxsemiconductor.com/an006

    That would let you upload new firmware to the SD card, then have the web server reboot itself with a new application image. His method only boots into RAM, I believe - it doesn't copy into EEPROM. That might be good for failsafe firmware?
  • Mike GMike G Posts: 2,702
    edited 2011-07-11 05:47
    Thanks Daniel, I'm using Kye's FAT driver and programming the target Spinneret was my original intention. Form some reason I could not get the HTML upload page to handle a binary so I wrote an upload program in .NET.

    Anyway, Jazzed came along and asked if I could program another Prop and I though hmmm.

    The .net code and SPIN code base
    http://forums.parallax.com/showthread.php?132562-Program-a-Propeller-with-the-Spinneret
    http://www.agaverobotics.com/spinneret/source/

    Site
    http://spinneret.servebeer.com:5000/
Sign In or Register to comment.