Solved

php url link

Posted on 2013-01-06
15
1,064 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
 
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 108

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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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 108

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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

These days socially coordinated efforts have turned into a critical requirement for enterprises.
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…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

705 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now