Jump to content

Recommended Posts

I have been able to combine output to produce one long string, which if copied and pasted into the browser, opens the required document.

 

echo "http://server/folder/";
echo "".  basename( $_FILES['uploadedfile']['name']). "";

 

This produces the output, for example, http://server/folder/file.doc (or whatever the extenson happens to be)

 

However - I am unsure to to create a URL from this?

 

Any pointers appreciated - especially if I am going about this in completely the wrong way. This is the first time I have done this.

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/40333-solved-create-a-url-from-php-output/
Share on other sites

If the folder is already inside your wwwroot, then you're all set ... you just have to create a link, or redirect the browser.  Your URL would be "http://www.yoursite.com/folder/document.ext"

 

To make it a string, just plug those items into a variable and echo the variable:

 

<?php
$url = "http://server/folder/";
$url .=  basename( $_FILES['uploadedfile']['name']). "";

echo "<a href='".$url."'>".$url."</a>";
?>

 

That should output:

 

<a href="http://server/folder/file.doc">http://server/folder/file.doc</a>

 

And if file.doc is within your wwwroot directory (ie, somewhere the server allows browser access), you'll be fine.

 

(monk.e.boy beat me to it!)

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.