i was able to upload files to https://demo.magnolia-cms.com which is 5.4.9… 

here a bit cleaned version of the poc above
[code]
<?php 

/*

poc fileupload magnolia

php script for php cli
adjust the $host, $path, $ssl, $filePath, $fileName to your needs

*/

$host = "demo.magnolia-cms.com";
$path = "/"; 
$ssl = true;
$filePath = "/Users/beni/Desktop";
$fileName = "yourfile.png";

if($ssl) {     
  $schema = "https";
  $port = "443"; 
} else {
  $schema = "http";
  $port = "80"; 
}

$url = "$schema://".$host.':'.$port.$path; 

$boundary = "benisboundaryBl9Kx9ONpfAmwkdA";
$content = file_get_contents($filePath."/".$fileName); 
$blankSize = 256;

$data    = "------$boundary\r\n"; 
$data   .= "Content-Disposition: form-data; name=\"myFile\"; 
filename=\"$fileName\"\r\n"; 
$data   .= "Content-Type: application/octet-stream\r\n\r\n"; 
$data   .= "$content\r\n"; 
$data   .= "------$boundary\r\n"; 
$data   .= "Content-Disposition: form-data; name=\"myBlankStuff\"\r\n\r\n"; 
for($i = 0;$i < $blankSize;$i++){
  $data .= " "; 
}
$data   .= "\r\n"; 
$data   .= "------$boundary--\r\n\r\n\r\n\r\n"; 

$contentLength = strlen($data)-$blankSize;

$packet  = "POST ".$url." HTTP/1.1\r\n"; 
$packet .= "Host: ".$host."\r\n"; 
$packet .= "User-Agent: POC Magnolia Fileupload\r\n"; 
$packet .= "Content-Type: multipart/form-data; boundary=----$boundary\r\n"; 
$packet .= "Accept-Language: en-us,en;q=0.5\r\n"; 
$packet .= "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\r\n"; 
$packet .= "Content-Length: ".$contentLength."\r\n\r\n\r\n\r\n"; 
$packet .= $data; 

if($ssl) {
        $sock = fsockopen('ssl://'.$host,$port); 
} else {
        $sock = fsockopen($host,$port); 
}
stream_set_timeout($sock, 5); 

if (!$sock) { 
  echo 'No response from '.$host."\n"; 
  die; 
} 

fputs($sock,$packet); 
$response = ''; 
while (!feof($sock)) { 
  $response .= fgets($sock); 
} 
fclose($sock); 

echo "############### REQUEST ##############\n";
echo $packet;
echo "############### RESPONSE #############\n";
echo $response;
echo "################ DONE ################\n";

            
?> 
[/code]

you can check if the file is in the demo instance with the groovy console:
[code]
myList = Path.getTempDirectory().listFiles()
myList.each{println it}
[/code]

-- 
Context is everything: 
http://forum.magnolia-cms.com/forum/thread.html?threadId=0c7666f1-0a4b-439b-8efb-dbe287fecd0d


----------------------------------------------------------------
For list details, see: http://www.magnolia-cms.com/community/mailing-lists.html
Alternatively, use our forums: http://forum.magnolia-cms.com/
To unsubscribe, E-mail to: <dev-list-unsubscr...@magnolia-cms.com>
----------------------------------------------------------------

Reply via email to