0

Hi, everybody

i have problem in fileuplaod.apache error log display the following error mesg

File does not exist: C:/wamp/www/uploads/planbooks/0f3d1d9a2ac7fbaf6ed4b4c266901eb579e2e658.jpg, 

but i creates folder in uploads/planbooks

class PlanbookForm extends BasePlanbookForm

{

public function configure()

 {


  parent::configure();

 $this->useFields(array('photo','title_name','country_id','zone_id','place','itinerary','occasion','date','description'));
  $this->widgetSchema['photo'] = new sfWidgetFormInputFileEditable(array('label' =>'photo','file_src' => '/'.sfConfig::get('sf_web_upload_dir').'/uploads/planbooks/' .$this->getObject()->getPhoto(),
  'is_image' => true,
  'edit_mode' => !$this->isNew(),
  'template' => '<div class="sublabel">%file%<br />%input%<br />%delete% %delete_label%</div>',

  ));
  // $this->setvalidator['photo', new sfValidatorFile();
 $this->setvalidator('photo', new sfValidatorFile(array('required'=>false,
  'path' => sfConfig::get('sf_upload_web_dir').'/planbooks',
  'mime_types' =>'web_images',));*/
   //$this->embedForm('photo' ,new PhotoForm());


 }

} 


  This is my action file.

    public function executeNew(sfWebRequest $request)
  {
    $this->form = new PlanbookForm();
  $this->editFormFields=array('title_name'=>'title_name','photo'=>'photo','country_id'=>'country_id','zone_id'=>'zone_id','place'=>'place','occasion'=>'occasion','Itinerary'=>'itinerary','description'=>'description');

  // $this->form->getValue('photo')->save(sfConfig::get('sf_upload_web_dir'));
$this->form->getObject()->getPhoto();
   $error = array();

$this->planbook =$planbook;
$this->error = $error;
$this->setTemplate("edit");
}

 public function executeUpdate(sfWebRequest $request)
  {
    $this->forward404Unless($request->isMethod(sfRequest::POST) || $request->isMethod(sfRequest::PUT));
$planbook = Doctrine_Core::getTable('Planbook')->find(array($request->getParameter('id')));
  //  $this->form = new PlanbookForm($planbook);

   // $this->processForm($request, $this->form);
  $result=$this->processForm($request);
return $this->renderText($result);

    $this->setTemplate('edit');
  }


   protected function processForm(sfWebRequest $request, sfForm $form)
  {
  $formPost=$request->getParameter('planbook');
  if(!$planbook=Doctrine::getTable('Planbook')->find($formPost['id'])){
 $planbook= new Planbook();
}
  $planbook->fromArray($formPost);

$this->form->getObject()->getPhoto();
 $planbook->save();
//$this->redirect('@planbook_view='.$planbook->getid());
    //$form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
    $form->bind($request->getParameter('planbook'), $request->getFiles('planbook'));
    //if ($form->isValid())
   //{
$planbook = $form->save();
$this->form->getValue('photo')->save(sfConfig::get('sf_upload_web_dir'));

      $this->redirect('planbook/edit?id='.$planbook->getId());
//$request->getFiles($this->form->getName());
    //$this->form->getValue('photo')->save(sfConfig::get('sf_upload_web_dir'));
  }

index.php
<div><img src="/uploads/planbooks/<?php echo $planbook['photo'] ?>"  alt="<?php echo $planbook['photo'] ?>"  width="40" height="40" /></div>

anybody plz help me.

2
Contributors
1
Reply
2
Views
5 Years
Discussion Span
Last Post by JudgeyD
0

Rather than saving to pre-defined directory, have you tried adding your own path string for to test?

Try this:

//$this->form->getValue('photo')->save(sfConfig::get('sf_upload_web_dir'));

To this:

$this->form->getValue('photo')->save("/uploads/planbooks/));

Also make sure that the save directory is chmodded to 0777 or 777 to ensure ou have permissions to save the image..

Hope this helps.

DJ

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.