0

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 :)

4

1 に答える 1

1

アップロードされたファイルのユーザーは、PHP が実行されているユーザーになります。同じphpインスタンスからファイルをアップロードして操作しているため、完全なファイル権限が必要です。

于 2012-07-19T01:10:05.410 に答える