Hello. i want integrate XUpload to my yii application. But i have 2 problems:
- after upload image they correctly saved to tmp folder
//protected/controllers/SiteController.php (line 95)
//Move our file to our temporary dir
$model->file->saveAs( $path.$filename );
chmod( $path.$filename, 0777 );
But in model when tmp image must move to another folder and rename to real image name (exmaple: photo.jpg)
//protected/models/Images.php (line 108)
if (rename($image["path"], $path . $image["filename"])) {
chmod($path . $image["filename"], 0777);
$img = new Image();
var_dump($img);
$img->size = $image["size"];
$img->mime = $image["mime"];
$img->name = $image["name"];
$img->source = "/images/uploads/{$this->id}/" . $image["filename"];
$img->somemodel_id = $this->id;
if (!$img->save()) {
//Its always good to log something
Yii::log("Could not save Image:\n" . CVarDumper::dumpAsString(
$img->getErrors()), CLogger::LEVEL_ERROR);
//this exception will rollback the transaction
throw new Exception('Could not save Image');
}
}
its not happen. image moved. but not rename. This is part of code not execute, but why?
- At this app i have 1 filed - title and XUpload form. I want to save all uploaded image to database, but i dint now how its make and i have error in step
I follow to this manual http://www.yiiframework.com/wiki/348/xupload-workflow/. Help me please. I am the second day trying to make it.
P.S. I upload my app - http://yadi.sk/d/ioG6Tvyq1yVRA for greater clarity. Dump of db in data folder. And sorry for my english