[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1203
  • Last Modified:

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
0
doctorbill
Asked:
doctorbill
  • 4
  • 4
  • 3
  • +3
3 Solutions
 
IanThCommented:
what does your download.php do?
0
 
acbxyzCommented:
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.
0
 
doctorbillAuthor Commented:
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
0
Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

 
IanThCommented:
so what is not working in your first question its not working and in your last this link is working fine ????
0
 
Ray PaseurCommented:
Can you please paraphrase the question?  I don't think I understand the issue.  Is this what you're looking for?

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

Open in new window

0
 
acbxyzCommented:
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.
0
 
doctorbillAuthor Commented:
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
0
 
IanThCommented:
what error do you get it could be a directory problem
0
 
acbxyzCommented:
Include a link into the title-property?
Sorry, this doesn't work with pure html. You need a javascript-tooltip to do it.

By the way, the <br /> are shown as plain text here (linux/firefox), no new line.
0
 
doctorbillAuthor Commented:
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
0
 
IanThCommented:
what code gets printed the href or the contents of download.php ?
0
 
Ray PaseurCommented:
A very, very good web site: http://sscce.org that describes a way forward with problems like this one.

At this point I am going to step back from this question and recommend that you hire a professional programmer who can get "hands on" in the scripts, HTML, data base and the other moving parts of this web site.  It's probably an easy fix once a programmer can see the site in action and test some changes to the code, and in respect of your time, I think that approach will get you a better answer, faster, than anything else I can do here.  

Best regards and best of luck with it, ~Ray
0
 
rinfoCommented:
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' ;
}
0
 
doctorbillAuthor Commented:
I managed to get the slimbox2 code (jquery) so I am looking at that in more detail
Sorry I was not so clear
0
 
mcnuteCommented:
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

0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 4
  • 4
  • 3
  • +3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now