Jump to content

[SOLVED] Hyperlink PHP Output...


gary_rip

Recommended Posts

Im using the following...

 

<form enctype="multipart/form-data" action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="post"> 
<b>What kind of zip are you giving me? A...</b><input type="hidden" name="MAX_FILE_SIZE" value="2048000" /> 
<select name="folder"> 
    <option>1/ 
    <option>2/ 
    <option>3/ 
</select><br /> 
<b>The file is...</b> <input name="userfile" type="file" /><br /> 
<input type="submit" value="Upload the zip!" /> 
</form> 

<?php 
if (@is_uploaded_file($_FILES["userfile"]["tmp_name"])) { 
    copy($_FILES["userfile"]["tmp_name"], $_POST["folder"] . $_FILES["userfile"]["name"]); 
    echo "www.testsite.com/files/" . $_POST["folder"] . $_FILES["userfile"]["name"];

} 
?> 

 

But when it out puts...

 

echo "www.testsite.com/files/" . $_POST["folder"] . $_FILES["userfile"]["name"];

 

(Which prints like www.testsite/files/1/test.zip)

 

I wish to make this a hyperlink to the same file.

 

Ive been trying...

 

cho "<a href=http://www.testsite.com/files/" . $_POST["folder"] . $_FILES["userfile"]["name"]>"www.garyrip.com/files/" . $_POST["folder"] . $_FILES["userfile"]["name"]</a>";

 

with no luck...

 

Any ideas?

Link to comment
Share on other sites

Try:

echo "<a href='http://www.testsite.com/files/" . $_POST["folder"] . $_FILES["userfile"]["name"]'>"www.garyrip.com/files/" . $_POST["folder"] . $_FILES["userfile"]["name"]</a>";

 

To specify what I changed: I put single quotes around href.

Link to comment
Share on other sites

Well, to keep up with the standards, only use double quotes in your HTML tags. I would do like this:

 

<?php
echo '<a href="http://www.testsite.com/files/'.$_POST['folder'].$_FILES['userfile']['name'].'">www.garyrip.com/files/'.$_POST['folder'].$_FILES['userfile']['name'].'</a>';
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.