-3

I was wondering how to send a image, like a Jpg, to a PHP file so that it can be uploaded to a folder named uploads (example)?

Can anyone write the scripts for me just so I can analyze them and learn from them?

Svid1
  • 1
  • 1

2 Answers2

0

create php file and save it on your server

<?
if ( isset ( $GLOBALS["HTTP_RAW_POST_DATA"]) ) {

    //the image file name
    $fileName = "Image1"

    // get the binary stream
    $im = $GLOBALS["HTTP_RAW_POST_DATA"];

    //write it
    $fp = fopen($fileName, 'w');
    fwrite($fp, $im);
    fclose($fp);

    $arr = array ( "success" => "true", "file" => $fileName );
    echo json_encode($arr);

}  else {

    $arr = array ( "fail" => "true", "error" => "Header data set incorrectly" );
    echo json_encode($arr);
}
?>

then from your c# code call that php file and pass image stream

Armen Mkrtchyan
  • 921
  • 1
  • 13
  • 34
0

Did you try to search on the almighty Google? Here is a tutorial specific for what you need

You will need to make it so people can't upload malicious PHP files like in this stackoverflow question

Community
  • 1
  • 1
Martijn Nosyncerror
  • 172
  • 1
  • 3
  • 16