I am using following method to upload and convert the pdf file using image magic. The create method is working but the image is not being uploaded in the respective directory.
public function actionCreate()
{
$model=new Alerts;
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if(isset($_POST['Alerts']))
{
$model->attributes=$_POST['Alerts'];
$model->infoFile=CUploadedFile::getInstance($model,'infoFile');
$pdf_file = $model->infoFile->name;
$save_to = $model->getUploadPath()."sample.jpg";
if($model->save()){
I can assure that webserver has write permission to $model->getUploadPath() which is Yii::getPathofAlias(‘webroot’).’/uploads/’; and Image Magic is properly installed and configured in the webserver
if(isset($_POST['Alerts']))
{
$model->attributes=$_POST['Alerts'];
$pdf_file = CUploadedFile::getInstance($model,'infoFile'); //Gets object of uploaded file and assigns to $pdf_file var
if($pdf_file)
{
$pdf_file_name = $pdf_file->name; //Create another var and assign only the file name to it
$model->infoFile = $pdf_file_name; //Assign the file name to the model attribute, so that the same as is saved to db
$save_to = $model->getUploadPath()."sample.jpg";
if($model->save()){
if($pdf_file_name)
{
$pdf_file->saveAs($save_to); //Run the saveAs on the $pdf_file object and save the file to the save path defined above
//Now that the file has been saved to the folder, and the file name to the db, run any other image manipulation code here
// exec('convert $model->infoFile->name -colorspace RGB $model->getUploadPath().$image',$output,$return_var);
// exec('convert "'.$pdf_file.'" -colorspace RGB -resize 800 "'.$save_to.'"', $output, $return_var);
// Yii::log($model->infoFile,'trace','application');
// Yii::log($model->getUploadPath(),'info');
}
}
}