I have an app in which a user can upload a picture. I'm uploading the picture to the server in a folder and I store in the database the path to that picture (->http://server.com/images/picture1.jpeg). This is how I upload a picture:
if (isset($_FILES['image']['name'])
&& in_array($extension, $allowedExts)) {
$temp = explode(".", $_FILES["image"]["name"]);
$newfilename = round(microtime(true)) . '.' . $extension;
$target_path = $target_path . basename($newfilename);
$imagepath = "http://server.com/images/" . basename($newfilename);
...
}
How can I store the image, but compressed. I saw that any picture that I upload to facebook is around 100 KB. How can I achieve something similar or what would you recommend ?