Jaswinder Posted May 30, 2013 Share Posted May 30, 2013 hello friends.. i have uploaded the images ,but their paths are different.. e.g upload/dancing/images/filename.jpg upload/singing/images/filename.jpg upload/fashion/images/filename.jpg i want to show all the images by clicking on a button.... How do i give path to all these..??? i am trying this code <img src="upload/../images/<?php $f['images'];?>"> here <?php $f['images'];?> is a file name coming from database but getting no result... and also the same way i want to show pdf and videos and they are also uploaded in different folders and their name are coming from database... any suggestions??? Quote Link to comment https://forums.phpfreaks.com/topic/278578-view-uploaded-images-pdf-videos/ Share on other sites More sharing options...
gizmola Posted May 30, 2013 Share Posted May 30, 2013 Possibly the tip of the iceberg in terms of your problems, but this: <?php $f['images']; Has to be either: <?= $f['images'] ?> or <?php echo $f['images']; ?> Quote Link to comment https://forums.phpfreaks.com/topic/278578-view-uploaded-images-pdf-videos/#findComment-1433122 Share on other sites More sharing options...
Jaswinder Posted May 30, 2013 Author Share Posted May 30, 2013 Oops sorry my mistake... i used <?php echo $f['images']; ?> but no results.... it shows nothing Quote Link to comment https://forums.phpfreaks.com/topic/278578-view-uploaded-images-pdf-videos/#findComment-1433135 Share on other sites More sharing options...
jazzman1 Posted May 30, 2013 Share Posted May 30, 2013 (edited) I think, It's pretty simple. Find all directories, sub-directories, grep all jpg files and save them paths inside txt file for instance, trim the file names, loop and put all values inside an array, then just display all of them. That's all Edited May 30, 2013 by jazzman1 Quote Link to comment https://forums.phpfreaks.com/topic/278578-view-uploaded-images-pdf-videos/#findComment-1433222 Share on other sites More sharing options...
gizmola Posted May 30, 2013 Share Posted May 30, 2013 For html, you need to provide either an absolute path or a relative path. In your case you are passing a relative path. However, I would never recommend a relative path like this: somedir/someimage.jpg Without the leading slash, the server assumes that this is relative to the page/script that is executing. You should know what asset you're trying to deliver and specify that as a specific relative path, from the webroot directory of your site. This is not to be confused with the actual directory on the server. For example if my actual path is: /var/html/mysite/upload/singing/filename.jpg But the webroot as configured in my webserver, is actually /var/html/mysite, then the specific relative path to filename.jpg in an ing src= would be: <img src="/upload/singing/filename.jpg"> So in your case your paths to the images are most likely going to be: <img src="/upload/dancing/images/filename.jpg"> <img src="/upload/singing/images/filename.jpg"> <img src="/upload/fashion/images/filename.jpg"> Quote Link to comment https://forums.phpfreaks.com/topic/278578-view-uploaded-images-pdf-videos/#findComment-1433258 Share on other sites More sharing options...
jazzman1 Posted May 30, 2013 Share Posted May 30, 2013 (edited) When I was reading the post at night something similar jump on the top of my head. I made the test with two different directories and 4 images (jpg and jpeg). Just replace my paths to the folders with your. Here is it: <?php $src = "find images/ gallery/ | grep --basic-regexp '\.[jpeg]' > images.txt"; $exc = shell_exec($src); $lines = array_map("trim", file('images.txt')); $output = array(); foreach ($lines as $line) { $output[] = '<img src=' . $line . ' alt=someImage />'; } ?> <!DOCTYPE html> <html> <head> <script> function displayImages() { document.getElementById("images").innerHTML = "<?php echo $output[0].$output[1].$output[2].$output[4]; ?>"; } </script> </head> <body> <div id="images"></div> <button onclick="displayImages()">Display me</button> </body> </html> Instead of $output[0], $output[1], so on.... loop the indexes with foreach. Edited May 30, 2013 by jazzman1 Quote Link to comment https://forums.phpfreaks.com/topic/278578-view-uploaded-images-pdf-videos/#findComment-1433284 Share on other sites More sharing options...
Jaswinder Posted May 31, 2013 Author Share Posted May 31, 2013 friends thanks for your replies.. but i am getting more confused .... do anyone have more simpler answer or just explain me the above answers more simply.. so that i can give it a shot.. Quote Link to comment https://forums.phpfreaks.com/topic/278578-view-uploaded-images-pdf-videos/#findComment-1433427 Share on other sites More sharing options...
jazzman1 Posted May 31, 2013 Share Posted May 31, 2013 (edited) Hey buddy, I gave you everything that you want to do. Just replace my paths to the directories (sub-directories) with yours - that's all. Edited May 31, 2013 by jazzman1 Quote Link to comment https://forums.phpfreaks.com/topic/278578-view-uploaded-images-pdf-videos/#findComment-1433431 Share on other sites More sharing options...
Jaswinder Posted June 2, 2013 Author Share Posted June 2, 2013 @jazzman1 . i found a more easy solution... while storing the filename in database.. i also inserted the events name with it... so now both events and filename get changed automatically .. it works great and i am getting images also Quote Link to comment https://forums.phpfreaks.com/topic/278578-view-uploaded-images-pdf-videos/#findComment-1433656 Share on other sites More sharing options...
Jaswinder Posted June 2, 2013 Author Share Posted June 2, 2013 Now for PDF's ... i uploaded them ... now i want to see those on frontend... how could i ??? i searched the web.. and i came accross PDF thumbnailing... should i go with that or any other options are there???? Quote Link to comment https://forums.phpfreaks.com/topic/278578-view-uploaded-images-pdf-videos/#findComment-1433657 Share on other sites More sharing options...
jazzman1 Posted June 2, 2013 Share Posted June 2, 2013 Good for you, that's the easiest way, much more elegant and flexiable So, about PDFs, I could suggest you to provide a link for download styling with a pdf web logo. Something like that - http://www.adobe.com/misc/linking.html#pdficon Quote Link to comment https://forums.phpfreaks.com/topic/278578-view-uploaded-images-pdf-videos/#findComment-1433669 Share on other sites More sharing options...
Jaswinder Posted June 3, 2013 Author Share Posted June 3, 2013 so you want to say .. that for each pdf file same image will repeat and there is a download link on that image for respective PDF's????? Quote Link to comment https://forums.phpfreaks.com/topic/278578-view-uploaded-images-pdf-videos/#findComment-1433766 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.