Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Okay no one has given an answer so I went off and discovered a project that details how to do this using either a Mac native app for a client or a PHP web page client. I modified some of the original server code slightly, just so you know I have tested this on my own site and it works for uploading files to a web server.</p> <p><strong>PHP Server (uploader.php)</strong></p> <pre><code>&lt;?php $target = "upload/"; $target = $target . basename( $_FILES['uploaded']['name'] ); $filename = "\"" . basename( $_FILES['uploaded']['name'] ) . "\""; $ok = 1; if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) { echo "$filename"; echo "was uploaded successfully"; } else { echo "$filename"; echo "upload failed"; } ?&gt; </code></pre> <p><strong>Web Client (index.php)</strong></p> <pre><code>&lt;form enctype="multipart/form-data" action="uploader.php" method="POST"&gt; &lt;input type="hidden" name="MAX_FILE_SIZE" value="100000" /&gt; Choose a file to upload: &lt;input name="uploaded" type="file" /&gt;&lt;br /&gt; &lt;input type="submit" value="Upload File" /&gt; &lt;/form&gt; </code></pre> <p><strong>Cocoa Client</strong></p> <p>The code for the Cocoa client is quite long and the code that goes with the above can be found <a href="http://www.cocoadev.com/index.pl?HTTPFileUploadSample" rel="noreferrer">here</a>. There is an <a href="http://cocoawithlove.com/2009/07/simple-extensible-http-server-in-cocoa.html" rel="noreferrer">alternative</a> here, which I think is better code, but I haven't tested it with the PHP server above. I expect you could modify it with minimal changes if any though.</p> <p><strong>Here is a basic way in Cocoa to send a text POST request to a webserver:</strong></p> <pre><code>NSString* content = [@"item=" stringByAppendingString:@"Something to Post"]; NSURL* url = [NSURL URLWithString:@"http://www.mysite.com/index.php"]; NSMutableURLRequest* urlRequest = [[NSMutableURLRequest alloc] initWithURL:url]; [urlRequest setHTTPMethod:@"POST"]; [urlRequest setHTTPBody:[content dataUsingEncoding:NSASCIIStringEncoding]]; </code></pre> <p>I like this because it is a minimal solution and you can build upon it easily and hopefully this can help someone else should they come across this :)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload