note 116561 deleted from imagick.writeimage by salathe
| From: | salathe@php.net | Date: | Fri, 06 Feb 2015 13:02:25 +0000 |
| Subject: | note 116561 deleted from imagick.writeimage by salathe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-201610@lists.php.net to get a copy of this message | ||
Note Submitter: LucasMoreno
----
<?php
// Saves "example.jpg" in Apache's dir (that's why has no error)
$im = new Imagick();
$im -> writeImage("example.jpg");
// Use instead the complete path:
function file_path($file){
$path =
explode("/",$_SERVER['DOCUMENT_ROOT'].$_SERVER['SCRIPT_NAME']);
for($i=0 ; $i < (substr_count($file, '../')+1); $i++){
unset($path[count($path)-1]);
}
$path = implode("/",$path);
$path = $path."/".$file;
return str_replace(array('../','./'),'',($path));
}
$im = new Imagick();
$im -> writeImage(file_path("example.jpg"));
?>