mssakib Posted August 6, 2011 Share Posted August 6, 2011 Hi i am using ghost script to make images from PDF. and i have made like this that i will upload a pdf file and after upload it would automatic convert that into images. But having a problem . My script Generates images from all pdf file avail in directory . I am using like this $inputPDFFileName ="upload/*.pdf"; $cmd = "some commands....."; $response = shell_exec($cmd); I know you would say that it generates because of *.pdf but how to fix that. Should i use something like this for each file as file.... or whatever. need some help:) Quote Link to comment https://forums.phpfreaks.com/topic/244030-file-system/ Share on other sites More sharing options...
phpSensei Posted August 6, 2011 Share Posted August 6, 2011 If you don't provide a pattern of file names to select from, then yes you need to do this file by file Quote Link to comment https://forums.phpfreaks.com/topic/244030-file-system/#findComment-1253195 Share on other sites More sharing options...
radiations3 Posted August 6, 2011 Share Posted August 6, 2011 The code i used to convert all of files into images <?php require_once('Connections/hammad.php'); ?> <?php mysql_select_db("bakery") or die(mysql_error()); $id=$_GET['id']; $image = mysql_query("SELECT img FROM pic WHERE `Desc`='".$id."'") or die(mysql_error()); $image = mysql_fetch_assoc ($image); $image = $image ['img']; header("content-type: image/jpg"); echo $image; ?> Quote Link to comment https://forums.phpfreaks.com/topic/244030-file-system/#findComment-1253197 Share on other sites More sharing options...
mssakib Posted August 6, 2011 Author Share Posted August 6, 2011 I don't want to use sql now. phpsensei can you write down the code along with mine bro . it would help me to understand Quote Link to comment https://forums.phpfreaks.com/topic/244030-file-system/#findComment-1253200 Share on other sites More sharing options...
phpSensei Posted August 6, 2011 Share Posted August 6, 2011 OP, are you image names stored in a mysql table? Quote Link to comment https://forums.phpfreaks.com/topic/244030-file-system/#findComment-1253209 Share on other sites More sharing options...
TeNDoLLA Posted August 6, 2011 Share Posted August 6, 2011 OP, are you image names stored in a mysql table? Probably not, if he just said he does not want to use SQL. And as mentioned already if you don't want all the pdf files to be converted you need to create some method to define the pdf files you want to convert. Maybe a select, maybe a search or something. Then put the files into array and convert the wanted pdf files only just like you do when you convert all the files in dir. Quote Link to comment https://forums.phpfreaks.com/topic/244030-file-system/#findComment-1253213 Share on other sites More sharing options...
mssakib Posted August 6, 2011 Author Share Posted August 6, 2011 NO BRO I AM NOT USING SQL . is there any way we can use $_FILES["file"]["name"] ? Quote Link to comment https://forums.phpfreaks.com/topic/244030-file-system/#findComment-1253215 Share on other sites More sharing options...
phpSensei Posted August 6, 2011 Share Posted August 6, 2011 Alright, I thought you did but didn't want to use it for some reason, sorry I misunderstood. However I still stand by the my first reply, a pattern that your files must follow is needed... such as, then you can loop through it with an iteration. filename_1.pdf filename_2.pdf filename_3.pdf Quote Link to comment https://forums.phpfreaks.com/topic/244030-file-system/#findComment-1253218 Share on other sites More sharing options...
mssakib Posted August 6, 2011 Author Share Posted August 6, 2011 I think using mysql would be good for now and for further development. so help on that would be appricated Quote Link to comment https://forums.phpfreaks.com/topic/244030-file-system/#findComment-1253301 Share on other sites More sharing options...
mssakib Posted August 6, 2011 Author Share Posted August 6, 2011 PROBLEM SOLVED . PLEASE CLOSE IT Quote Link to comment https://forums.phpfreaks.com/topic/244030-file-system/#findComment-1253348 Share on other sites More sharing options...
Pikachu2000 Posted August 6, 2011 Share Posted August 6, 2011 There's a 'Topic Solved' button below for you to mark the thread solved . . . Quote Link to comment https://forums.phpfreaks.com/topic/244030-file-system/#findComment-1253349 Share on other sites More sharing options...
phpSensei Posted August 6, 2011 Share Posted August 6, 2011 Apparently it isn't solved. If you want to use Database then I suggest you store all of your files in a table file_tbl ----------- id - int(11) unique file - varchar(225) filepath - varchar(225) dateposted - datetime id | file | filepath | dateposted -------------------------------- ----------------------------- 0 | file.pdf | upload/ | YYY-MM-DD HH:MM:SS 1 | abc.pdf | upload/ | YYY-MM-DD HH:MM:SS 2 | sum1.pdf | upload/ | YYY-MM-DD HH:MM:SS 3 | lol.pdf | upload/ | YYY-MM-DD HH:MM:SS 4 | php.pdf | upload/ | YYY-MM-DD HH:MM:SS 5 | upl.pdf | upload/ | YYY-MM-DD HH:MM:SS 6 | 111.pdf | upload/ | YYY-MM-DD HH:MM:SS Now you can do this $query = mysql_query("SELECT `id`,`file`,`filepath`FROM `file_tbl` ORDER BY `dateposted` DESC") or die(mysql_error()); while($row = mysql_fetch_fetch_array($query)){ $inputPDFFileName = $row['filepath'] . $row['file']; $cmd = "some commands....."; $response = shell_exec($cmd); } Quote Link to comment https://forums.phpfreaks.com/topic/244030-file-system/#findComment-1253421 Share on other sites More sharing options...
AyKay47 Posted August 6, 2011 Share Posted August 6, 2011 PROBLEM SOLVED . PLEASE CLOSE IT ha... Quote Link to comment https://forums.phpfreaks.com/topic/244030-file-system/#findComment-1253422 Share on other sites More sharing options...
phpSensei Posted August 6, 2011 Share Posted August 6, 2011 He Pm'ed me just now btw asking for help. Quote Link to comment https://forums.phpfreaks.com/topic/244030-file-system/#findComment-1253428 Share on other sites More sharing options...
mssakib Posted August 7, 2011 Author Share Posted August 7, 2011 thx php sensei. will try it Quote Link to comment https://forums.phpfreaks.com/topic/244030-file-system/#findComment-1253631 Share on other sites More sharing options...
phpSensei Posted August 7, 2011 Share Posted August 7, 2011 Np, keep it in the thread btw, so others can help and see, thank you my friend. Quote Link to comment https://forums.phpfreaks.com/topic/244030-file-system/#findComment-1253678 Share on other sites More sharing options...
mssakib Posted August 7, 2011 Author Share Posted August 7, 2011 Yap going good. During each upload it saves those data in sql. I also gave each a unique ID . Now a little problem is . How call that filename from sql and give the generated file a unique name. Like this $filePath= "upload/ I want here the filename from sql": // Do i need to use mysql_query ? and then shell_exec( gs -sDEVICE=jpeg -sOutputFile=s_%d.jpg -dSAFER -dBATCH -dNOPAUSE -r100×100 $filePath); //-sOutputFile=s_%d.jpg = File name and %d will generate name according to page num. But here is a problem suppose i have a pdf file named s.pdf and from it it generates S_1.jpg and when i put another pdf ... it removes my previous image and also names it as s_1.jpg. So how to give the -sOutputFile a unique name each time ? thanks a lot helping. Learning php is interesting Quote Link to comment https://forums.phpfreaks.com/topic/244030-file-system/#findComment-1253691 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.