Link to home
Start Free TrialLog in
Avatar of doctorbill
doctorbillFlag for United Kingdom of Great Britain and Northern Ireland

asked on

php url link

Here is part of my page code which is working perfectly:
 
<div id="copyright-box"><h1 id="wcs-title">Robert Simpson Photography<br />---------</h1></div>
  <div id="info-box"align="centre">
      <h1 id="wcs-title">Thebytesizedimage Portfolio</h1>
      <p id="wcs-description">
      </p>
    </div><br />
  
  
  <div id="grid-box">
      <ol id="wcs-list">
      <?php do { 
	      
	  ?>
    <li>
          <div class="thumbnail-box" style="width: 160px; height: 170px;"><span class="edge"></span><span class="container"><a href="<?php echo $row_imgs[im_prev]; ?>" title="<?php echo $row_imgs[im_name]; ?><br />2010<br />
<?php
$f = $row_imgs["im_hresSize"];
$size = filesize($f) * .000001;
echo $f . " is " . $size . " Megabytes.";
?>
<br />Robert Simpson Photography" rel="lightbox[Natalia Glinoer Portfolio]"><img src="<?php echo $row_imgs[im_thumb]; ?>" title="<?php echo $row_imgs[im_name]; ?>" alt="" class="thumbnail" id="wcs-img-b360a63e-dca9-4918-a3e6-936256e348a1"></a></span><div id="wcs-caption-b360a63e-dca9-4918-a3e6-936256e348a1" class="caption-box"><a href="download.php?file=<?php echo $row_imgs[im_hres]; ?>">Download Image</a></div>
          </div>
        </li>
        <?php } while ($row_imgs = mysql_fetch_assoc($imgs)); ?>
    
  </ol>
    </div>

Open in new window

This is the section I need to edit:
<?php
$f = $row_imgs["im_hresSize"];
$size = filesize($f) * .000001;
echo $f . " is " . $size . " Megabytes.";
?>

Open in new window

I need to include the following url in the above section (under edit) so that the image download takes place on clicking the "Download image" text
<a href="download.php?file=<?php echo $row_imgs[im_hres]; ?>">Download Image</a>

I can't get it to work correctly
Avatar of IanTh
IanTh
Flag of United Kingdom of Great Britain and Northern Ireland image

what does your download.php do?
First, you should switch from foot-controlled loop do{ ... } while (); to a head controlled loop while () {...}. In the first run your array is empty.
Second, the indices in squared brackets are no constants, are they? http://de.php.net/manual/en/function.define.php
Those names should be enclosed with quotes, either single or double.

But what exactly is your problem with the code? Besides the two aspects above it looks good.
Avatar of doctorbill

ASKER

If you look at the following section:
<a href="download.php?file=<?php echo $row_imgs[im_hres]; ?>">Download Image</a>

clicking on the "download Image" link sends image details to the download.php page and the script on this page causes the image to be downloaded.
This link is working fine
so what is not working in your first question its not working and in your last this link is working fine ????
ASKER CERTIFIED SOLUTION
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Well, we don't know what is in download.php, we don't know how the data is stored in your db, we don't know where you can find your images in your filesystem. The only thing you told us is that anything doesn't work.
How can we help in this case?

As I said before, we need to know how it works now and what's wrong with how it is working. With the given information we can't see it.
I simply want to include this link:
<a href="download.php?file=<?php echo $row_imgs[im_hres]; ?>">Download Image</a>

into this section:
<?php
$f = $row_imgs["im_hresSize"];
$size = filesize($f) * .000001;
echo $f . " is " . $size . " Megabytes.";
?>

It does not work correctly
what error do you get it could be a directory problem
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Response to Ray:

<?php
$f = $row_imgs["im_hresSize"];
$size = filesize($f) * .000001;
echo $f . " is " . $size . " Megabytes.";
?>
<!-- INSERTED CODE HERE -->
<a href="download.php?file=<?php echo $row_imgs[im_hres]; ?>">Download Image</a>
<!-- END OF INSERTED CODE -->
<br />Robert Simpson Photography" rel="lightbox[Natalia
...

I tried this but I just get the code being printed out on the screen
what code gets printed the href or the contents of download.php ?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rinfo
rinfo

if your intention is that when user clicks on link it will download file mentioned in the get variable to the user.
<a href="download.php?file=<?php echo $row_imgs[im_hres]; ?>">Download Image</a>
first you need to ascertain whether file=filename is populated with file name.
This you can check by putting echo $row_imgs[im_hres]." download file name ';
before the link .
download.php should have something like this

$download_file = $_GET["file"] ;
if (isset($download_file){
header('Content-type: text/plain');
header('Content-Disposition: attachment; filename="$download_file");
readfile("$download_file");
}
else
{
     echo 'No download file name' ;
}
I managed to get the slimbox2 code (jquery) so I am looking at that in more detail
Sorry I was not so clear
You can try to include this in the first block of php like this:

<?php
$f = $row_imgs["im_hresSize"];
$size = filesize($f) * .000001;
echo $f . " is " . $size . " Megabytes.";

<!-- INSERTED CODE HERE -->
echo '<a href="download.php?file='.$row_imgs[im_hres].'">Download Image</a>';
?>

Open in new window