This works:
function upload($directory) {
App::import('Vendor', 'UploadedFiles', array('file' => 'UploadedFiles.php'));
echo $directory;
$this->_saveUploadedFiles('C:/xampp/htdocs/freetickets/app/webroot/img/gallery/zantje_11042/');
}
function _saveUploadedFiles($galleryPath) {
$absGalleryPath = $galleryPath;
$absThumbnailsPath = 'C:\xampp\htdocs\freetickets\app\webroot\img\gallery\zantje_11042\thumbnails\\';
//Iterate through uploaded data and save the original file, thumbnail, and description.
while(($file = UploadedFiles::fetchNext()) !== null) {
$fileName = $file->getSourceFile()->getSafeFileName($absGalleryPath);
$file->getSourceFile()->save($absGalleryPath . '/' . $fileName);
$thumbFileName = $file->getThumbnail(1)->getSafeFileName($absThumbnailsPath);
$file->getThumbnail(1)->save($absThumbnailsPath . '/' . $thumbFileName);
}
}
But this doesn't:
function upload($directory) {
App::import('Vendor', 'UploadedFiles', array('file' => 'UploadedFiles.php'));
echo $directory; //echoes C:/xampp/htdocs/freetickets/app/webroot/img/gallery/zantje_11042/
$this->_saveUploadedFiles($directory);
}
function _saveUploadedFiles($galleryPath) {
$absGalleryPath = $galleryPath;
$absThumbnailsPath = 'C:\xampp\htdocs\freetickets\app\webroot\img\gallery\zantje_11042\thumbnails\\';
//Iterate through uploaded data and save the original file, thumbnail, and description.
while(($file = UploadedFiles::fetchNext()) !== null) {
$fileName = $file->getSourceFile()->getSafeFileName($absGalleryPath);
$file->getSourceFile()->save($absGalleryPath . '/' . $fileName);
$thumbFileName = $file->getThumbnail(1)->getSafeFileName($absThumbnailsPath);
$file->getThumbnail(1)->save($absThumbnailsPath . '/' . $thumbFileName);
}
}
Only difference is the $this->_saveUploadedFiles('C:/xampp/htdocs/freetickets/app/webroot/img/gallery/zantje_11042/') and one with a variable as path: $this->_saveUploadedFiles($directory);
So why doesn't it work when using $directory, even if $directory echoes C:/xampp/htdocs/freetickets/app/webroot/img/gallery/zantje_11042/ ?
Thanks