简体   繁体   中英

How to pass image from one page to other using PHP?

I have been trying to execute the code for long time but rest then my image all other variables are working. My images are stored in server folder called "uploaded".

I have two pages called "show.php" and "readmore.php", and I want to pass the image from show.php to readmore.php but other then image all the variables are displaying in readmore.php.

My code for show.php

<a class="btn" href="readmore.php?ad_title=<?php echo $rec['ad_title']; ?> & price= <?php echo $rec['price']; ?> & address= <?php echo $rec['address']; ?>  & phone= <?php echo $rec['m_number']; ?> & description= <?php echo $rec['description']; ?> & contact_name= <?php echo $rec['contact_name'] ; ?> & photo_name= <?php echo $rec['photo_name']?>;">

My code for readmore.php (I am displaying here two of the variables along with the image)

 <div class="control-group">
                    <label class="control-label">About the book</label>
                    <div class="controls">
                        <label class="checkbox">
                        <?php echo $_GET['description'];?>
                        </label>
                    </div>
                  </div>
                   <div class="control-group">
                    <label class="control-label">About the book</label>
                    <div class="controls">
                        <label class="checkbox">
                       <td id="pic" width="300px"><img src= "../uploaded/<?php echo $_GET['photo_name'];?>" style="border-radius:5px; padding:3px; "/></td>
                        </label>
                    </div>
                  </div>

Learn to debug:

On first lines of readmore.php dump the superglobal variable $_GET and see whether value of $_GET['photo_name'] is coming or not.

Eg.

echo "<pre>"; 
print_r($_GET);
echo "</pre>"; 

PS <pre> tag is just for formatting the output. print_r dumps the values of $_GET.

If you see value of 'photo_name' index in the GET array, there should be some errors in your image path.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM