这有效:
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);
}
}
但这不是:
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);
}
}
唯一差异是$this->_saveUploadedFiles('C:/xampp/htdocs/freetickets/app/webroot/img/gallery/zantje_11042/')
,其中一个变量为路径:$this->_saveUploadedFiles($directory);
那么为什么在使用$ directory时它不起作用,即使$directory
回应C:/ xampp / htdocs / freetickets / app / webroot / img / gallery / zantje_11042 /?
由于
答案 0 :(得分:0)
检查将/和\作为文件夹分隔符放在路径中的方式。