Solved

php url link

Posted on 2013-01-06
15
1,075 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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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 109

Accepted Solution

by:
Ray Paseur earned 334 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 166 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 109

Assisted Solution

by:Ray Paseur
Ray Paseur earned 334 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: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

828 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