I'm trying to implement photo uploading and resizing in PHP (I'm using the LAMP stack and the Imagick extension for resizing). However, every time I try to upload a file, the file has the ownership set to www-data by default, which makes it impossible to apply any changes to the file. The following is the code i'm using:
<?php
if (is_uploaded_file($_FILES['picture']['tmp_name'])){
$photoPath = $_SERVER['DOCUMENT_ROOT'] . '/photo_app/uploads/' . $_FILES['picture']['name'];
if (move_uploaded_file($_FILES['picture']['tmp_name'], $photoPath)){
$image = new Imagick($photoPath);
$image -> scaleImage(250, 250, true);
$image -> writeImage($photoPath);
}
}
?>
The photo gets moved in the right place, but no resizing occurs because of the ownership issue. Is there a way to resolve this? Thanks :)