Jump to content

Recommended Posts

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???

Link to comment
https://forums.phpfreaks.com/topic/278578-view-uploaded-images-pdf-videos/
Share on other sites

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 by jazzman1

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">

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 by jazzman1

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

 

 

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.