I'm trying to convert php image upload script but having problem understanding PHP.
I just need to find out the way to access JPG snapshot using VB.net.
especially this part
$input = file_get_contents('php://input');
So I would like to do something like this
Dim originalBMP As New System.Drawing.Bitmap(***I need value here ******)
'Here is entire code
// We only need to handle POST requests:
if(strtolower($_SERVER['REQUEST_METHOD']) != 'post'){
exit;
}
$folder = 'uploads/';
$filename = md5($_SERVER['REMOTE_ADDR'].rand()).'.jpg';
$original = $folder.$filename;
// The JPEG snapshot is sent as raw input:
$input = file_get_contents('php://input');
if(md5($input) == '7d4df9cc423720b7f1f3d672b89362be'){
// Blank image. We don't need this one.
exit;
}
$result = file_put_contents($original, $input);
if (!$result) {
echo '{
"error" : 1,
"message" : "Failed save the image. Make sure you chmod the uploads folder and its subfolders to 777."
}';
exit;
}
$info = getimagesize($original);
if($info['mime'] != 'image/jpeg'){
unlink($original);
exit;
}
// Moving the temporary file to the originals folder:
rename($original,'uploads/original/'.$filename);
$original = 'uploads/original/'.$filename;
echo '{"status":1,"message":"Success!","filename":"'.$filename.'"}';
The Flash movie makes a HTTP POST to your server-side script, using the Content-Type 'image/jpeg'. This is a NON-STANDARD method which is unlike submitting a form from a web page. If you are using PHP, the JPEG data will NOT be in the normal
$_POST associative array. Instead, you should read it from the special PHP wrapper: 'php://input'. For example:
$jpeg_data = file_get_contents('php://input');
You can write this raw, binary JPEG data to a file handle using the PHP function file_put_contents():
Any output from your script is passed back through the Flash movie to the JavaScript code, which in turn passes it to your onComplete callback function.
For example, if you want your script to pass back a URL to the JPEG image, save the file where you want it, and construct a URL to the file. Then simply print the URL to the output like this:
(This assumes you are saving the files to the current working directory)
aibip
Member
134 Points
185 Posts
Convert PHP img upload script to VB.net
Jul 31, 2011 11:27 PM|LINK
I'm trying to convert php image upload script but having problem understanding PHP.
I just need to find out the way to access JPG snapshot using VB.net.
especially this part
$input = file_get_contents('php://input');So I would like to do something like this
Dim originalBMP As New System.Drawing.Bitmap(***I need value here ******)
'Here is entire code
// We only need to handle POST requests: if(strtolower($_SERVER['REQUEST_METHOD']) != 'post'){ exit; } $folder = 'uploads/'; $filename = md5($_SERVER['REMOTE_ADDR'].rand()).'.jpg'; $original = $folder.$filename; // The JPEG snapshot is sent as raw input: $input = file_get_contents('php://input'); if(md5($input) == '7d4df9cc423720b7f1f3d672b89362be'){ // Blank image. We don't need this one. exit; } $result = file_put_contents($original, $input); if (!$result) { echo '{ "error" : 1, "message" : "Failed save the image. Make sure you chmod the uploads folder and its subfolders to 777." }'; exit; } $info = getimagesize($original); if($info['mime'] != 'image/jpeg'){ unlink($original); exit; } // Moving the temporary file to the originals folder: rename($original,'uploads/original/'.$filename); $original = 'uploads/original/'.$filename; echo '{"status":1,"message":"Success!","filename":"'.$filename.'"}';
reference url is
http://tutorialzine.com/2011/04/jquery-webcam-photobooth/
Thank you for your help
aibip
Member
134 Points
185 Posts
Re: Convert PHP img upload script to VB.net
Jul 31, 2011 11:35 PM|LINK
Server Side Code
The Flash movie makes a HTTP POST to your server-side script, using the Content-Type 'image/jpeg'. This is a NON-STANDARD method which is unlike submitting a form from a web page. If you are using PHP, the JPEG data will NOT be in the normal $_POST associative array. Instead, you should read it from the special PHP wrapper: 'php://input'. For example:
$jpeg_data = file_get_contents('php://input');You can write this raw, binary JPEG data to a file handle using the PHP function file_put_contents():
Any output from your script is passed back through the Flash movie to the JavaScript code, which in turn passes it to your onComplete callback function.
For example, if you want your script to pass back a URL to the JPEG image, save the file where you want it, and construct a URL to the file. Then simply print the URL to the output like this:
(This assumes you are saving the files to the current working directory)
(See "test.php" for a working example.)
I found this from this web site... It's over my head..
http://code.google.com/p/jpegcam/wiki/Instructions
aibip
Member
134 Points
185 Posts
Re: Convert PHP img upload script to VB.net
Aug 01, 2011 04:37 PM|LINK
Any takers?
I searched web for a while to find a solution and found that Request.FileStream may be do the job.
I'll keep on researching but any help would be great.
Thank you.