Jump to content

Upload file under Prestashop 1.6


zelakioui

Recommended Posts

 I am developping a module on prestashop 1.6,  i am using this code to upload picture :

 

if (!empty($_FILES))
{

           $name = reset(explode(".",$_FILES['coffretImg1']['name']));
           $ext = end(explode(".",$_FILES['coffretImg1']['name']));
         $filename = date('h:i:s A', strtotime('-1 hour'))." - ".$name.".".$ext;

          $tempFile = $_FILES['coffretImg1']['tmp_name'];
          $targetPath = $_SERVER['DOCUMENT_ROOT'] ."/prestashop/modules/coffretmod/uploads";
         $targetFile = str_replace('//','/',$targetPath) . $filename;


            if (!file_exists ( $targetPath ))

            {
                   mkdir(str_replace('//','/',$targetPath), 0755, true);
                    move_uploaded_file($tempFile,$targetFile);
                   echo $filename;

            }

 

         else {
                      move_uploaded_file($tempFile,$targetFile);
                     echo $filename;
                    echo " moved ...$targetPath" ;

               }
}

else
{
          echo 'Invalid file type.';
   
}

 

 

everything is ok but i didin't find submitted file in uploads directory . i don't know where is the probleme

 

please i need your help ! .

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...