Im trying to integrate PHP Thumb with an flash uploader known as 'Uploadify'. Uploadify allows users to upload many different images at once. The problem I am having is that PHPThumb is not creating an thumbnails. When I run the php upload script directly, it returns '1'. I have all of the PHPThumb library files in the same directory with my upload script:
<?php
require_once 'ThumbLib.inc.php';
error_reporting(E_ALL);
$dor = $_GET['session_name'];
if (!empty($_FILES)) {
$tempFile = $_FILES['Filedata']['tmp_name'];
$targetPath = $_SERVER['DOCUMENT_ROOT'] . $_GET['folder'] . '/';
$targetPath = str_replace('//','/',$targetPath);
$targetFile = $targetPath . $_FILES['Filedata']['name'];
move_uploaded_file($tempFile,$targetFile);
}
echo '1';
$thumb = PhpThumbFactory::create($_FILES['Filedata']['name']);
$thumb->cropFromCenter(130, 80);
$thumb->save('files/Thumbs/'.$_FILES['Filedata']['name']);
$simp = simplexml_load_file($dor);
$node = $simp->addChild('pic');
$node->addChild('image', 'files/'.$_FILES['Filedata']['name']);
$node->addChild('thumb', 'files/Thumbs/'.$_FILES['Filedata']['name']);
$s = simplexml_import_dom($simp);
$s->saveXML($dor);
?>
I have tried using the same code to edit the static sample image and I get the same problem:
<?php
require_once 'ThumbLib.inc.php';
error_reporting(E_ALL);
$dor = $_GET['session_name'];
if (!empty($_FILES)) {
$tempFile = $_FILES['Filedata']['tmp_name'];
$targetPath = $_SERVER['DOCUMENT_ROOT'] . $_GET['folder'] . '/';
$targetPath = str_replace('//','/',$targetPath);
$targetFile = $targetPath . $_FILES['Filedata']['name'];
move_uploaded_file($tempFile,$targetFile);
}
echo '1';
$thumb = PhpThumbFactory::create('test.jpg');
$thumb->cropFromCenter(200, 100);
$simp = simplexml_load_file($dor);
$node = $simp->addChild('pic');
$node->addChild('image', 'files/'.$_FILES['Filedata']['name']);
$node->addChild('thumb', 'files/Thumbs/'.$_FILES['Filedata']['name']);
$s = simplexml_import_dom($simp);
$s->saveXML($dor);
$thumb->show();
?>
The situation is a little peculiar as I am copying all of the uploaded file names to an XML file using the simpleXML parser. Thats why I have some session variables running around in the background. I don't think this is part of the problem, but I thought I would explain the last part of my code.