Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

php url link

Posted on 2013-01-06
15
Medium Priority
?
1,115 Views
Last Modified: 2013-01-07
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
Comment
Question by:doctorbill
  • 4
  • 4
  • 3
  • +3
15 Comments
 
LVL 30

Expert Comment

by:IanTh
ID: 38748361
what does your download.php do?
0
 
LVL 10

Expert Comment

by:acbxyz
ID: 38748367
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
 

Author Comment

by:doctorbill
ID: 38748368
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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 30

Expert Comment

by:IanTh
ID: 38748381
so what is not working in your first question its not working and in your last this link is working fine ????
0
 
LVL 111

Accepted Solution

by:
Ray Paseur earned 1336 total points
ID: 38748382
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
 
LVL 10

Expert Comment

by:acbxyz
ID: 38748384
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
 

Author Comment

by:doctorbill
ID: 38748385
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
 
LVL 30

Expert Comment

by:IanTh
ID: 38748389
what error do you get it could be a directory problem
0
 
LVL 10

Assisted Solution

by:acbxyz
acbxyz earned 664 total points
ID: 38748391
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
 

Author Comment

by:doctorbill
ID: 38748396
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
 
LVL 30

Expert Comment

by:IanTh
ID: 38748399
what code gets printed the href or the contents of download.php ?
0
 
LVL 111

Assisted Solution

by:Ray Paseur
Ray Paseur earned 1336 total points
ID: 38748423
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
 
LVL 9

Expert Comment

by:rinfo
ID: 38750471
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
 

Author Closing Comment

by:doctorbill
ID: 38751029
I managed to get the slimbox2 code (jquery) so I am looking at that in more detail
Sorry I was not so clear
0
 
LVL 11

Expert Comment

by:mcnute
ID: 38751687
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

782 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question