I am trying to run convert 'sample_(2).pdf[1]' 'sample.jpg' through php exec like below
> exec(" convert 'sample_(2).pdf[1]' 'sample.jpg' ");
But it is not working in php but works great in terminal. I tried below codes also to check wethee exec is working with php.
echo exec('whoami'); //It is working and giving me result
exec("cp 'sample_(2).pdf' sample2.pdf");
//It is not working.
But all the commands are running in terminal. Any idea would help me. I am scratching my head for the last two days.
EDIT
I got it working. There were mistakes with my file path.
exec("cp $source $destination");after you've escaped properly using \ for command line. and running the script from the terminal runs it with the permissions of the user logged in, running it via web server runs it with your apache user (www-data on deb/httpd on RH) running it via ftp runs it as your ftp user. Ftp users are usually locked out from executing scripts anyway