Thursday, 26 September 2013

Find the size of a an image sent from Java to PHP as a byte array.

Find the size of a an image sent from Java to PHP as a byte array.

I am very new to PHP, Java is my domain. I have a specific problem that
when I upload a picture from my client side to be stored in the database,
before saving it I want to calculate the file size and it should be less
than 3mb. I am sending this file from Java as a byte array. I Googled
around and found that
$result_array = getimagesize($file);
can give me the file size, however it takes an argument which has to be a
file. How do I do it for a byte array? do I have to convert it first. I
beg pardon, this might be a naive question but consider my being new to
PHP.
So far my PHP looks like this:
<?php
require 'DbConnect.php';
$IMG= $_POST["Image"];
$IMG2= $_POST["Image2"];
$IMG3= $_POST["Image3"];
$IMG4= $_POST["Image4"];
$ID = $_POST["Seller_ID"];
$query2 = "INSERT INTO used_cars (Img, Img2, Img3, Img4) VALUES ('$IMG',
'$IMG2', '$IMG3', '$IMG4')";
mysql_query($query2) or die(mysql_error())
?>

No comments:

Post a Comment