I am re-writing the Mod Share Uploader in Insanity, but need a bit of help.
I want to send a POST request to scripts/upload.php with the following POST arguments;
title = filename of project
description = project notes
license = project license (pd, ms, or cc)
filetype = mod chosen (insanity11 in this case
editpass = blank
project = a file upload containing the project
How would I do this?
Offline
I couldn't find any docs on squeak.org either...
Offline
I coded one for dreamod; let me go find it.
EDIT: Ah yes, here we go.
This seems to work!
|t1 t2 |
t1_ WeakKeyAssociation new value: #('This is a test.').
t1 key: 'test'.
t2 _ #() asOrderedCollection.
t2 add: t1.
^ HTTPSocket httpPostDocument: 'www.blocks.scratchr.org/postPing.php' args: t2This code assigns the string "This is a test." to the arg "test" and passes the data, as the postPing.php page shows.
If you want more args, create WeakKeyAssociations. Each one represents an arg. Use the "value: (string)" method to give them the arg value and the "key: (string)" method to give them their names. Add them all to an OrderedCollection using "add: (WeakKeyAssociation)" and call this code at the end:
^ HTTPSocket httpPostDocument: (string with the url) args: (OrderedCollection)
Last edited by Greenatic (2012-08-19 21:14:59)

Offline
That's awesome Greenatic, I bookmarked it!
But how can you pass file data if all you can pass are strings? Is there a way to specify encoding/content type?
Offline
http://scratch.mit.edu/forums/viewtopic … 3#p1278593
I haven't really tested it so tell me how it works...
Offline
MathWizz wrote:
http://scratch.mit.edu/forums/viewtopic … 3#p1278593
I haven't really tested it so tell me how it works...
Thanks, I'll try it.
Offline
MathWizz wrote:
jvvg wrote:
This code appears to work! Thanks!
I tested it out, and it uploads test data fine. Now I just need to port the code.
![]()
So far, it's going well. If all works, I will have the uploader fully functioning in a minute or two.
Now that the Squeak portion works, I just need to get the PHP portion working.
Last edited by jvvg (2012-08-21 13:49:27)
Offline
Offline