2009
08.06
08.06
Hello,
I’ve just worked on something for a project of mine and I wanted to share this code with you.
It’s nothing new but good to know…
Ok so if you want to make a thumbnails of your php document you have to have imagemagick on your host and the permission to have some kind of shell from apache user to use the exec command.
Of your you will have to chmod to 777 your destination folder…
<?php
if($_POST){
if(isset($_FILES['pdf']))
{
$folder = './upload/';
$width=100;
$height=100;
$file = basename($_FILES['pdf']['name']);
if(move_uploaded_file($_FILES['pdf']['tmp_name'], $folder . $file))
{
exec("convert -geometry ".$width."x".$height." ".$folder.$file."[0] ".$folder.$file."_thumb.jpeg");
?><img src="./upload/<?=$file;?>_thumb.jpeg" /><?
}
else
{
echo 'Error';
}
}
} else {
?>
<form enctype="multipart/form-data" method="post">
<input type=file name=pdf>
<input type=submit name=sub value=go>
</form>
<?
}
?>
have fun !
No Comment.
Add Your Comment