chrisuk Posted February 27, 2007 Share Posted February 27, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/40333-solved-create-a-url-from-php-output/ Share on other sites More sharing options...
monk.e.boy Posted February 27, 2007 Share Posted February 27, 2007 echo '<a href="http://server/folder/'; echo basename( $_FILES['uploadedfile']['name']). '">Click here to download your file</a>'; Does this work? Please note that I have changed your quotes. monk.e.boy Quote Link to comment https://forums.phpfreaks.com/topic/40333-solved-create-a-url-from-php-output/#findComment-195152 Share on other sites More sharing options...
nloding Posted February 27, 2007 Share Posted February 27, 2007 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!) Quote Link to comment https://forums.phpfreaks.com/topic/40333-solved-create-a-url-from-php-output/#findComment-195153 Share on other sites More sharing options...
chrisuk Posted February 27, 2007 Author Share Posted February 27, 2007 Thanks Gents - that's done it. I had tried with the <a href> but not the syntax wrong! Appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/40333-solved-create-a-url-from-php-output/#findComment-195186 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.