Bricktop Posted July 15, 2009 Share Posted July 15, 2009 Hi all, I have an upload script that allows for image uploads to specified directories. The specified directory is a variable and can change. I would like to know how I can display a link to the uploaded file. Does anyone know how I can achieve this? Thanks Quote Link to comment Share on other sites More sharing options...
rhodesa Posted July 15, 2009 Share Posted July 15, 2009 The question is too vague. Please post some of your code. What is the value in that "variable" you speak of? Quote Link to comment Share on other sites More sharing options...
Bricktop Posted July 15, 2009 Author Share Posted July 15, 2009 Here is a snippet from the display part of the code: list($width,$height) = getimagesize($settings['uploadpath'].$file); $content .= '<div class="containercontent">'; $content .= '<div class="image"><div class="thumbnaildiv"><img src="'.$settings['adminthumbpath'].''.$file.'" alt="'.$file.'" class="thumbnail" /></div>'; $content .= '<div class="image">'; $content .= '<p class="image>Filename: '.$file.'</p>'; $content .= '<p class="image">Width: '.$width.' pixels</p>'; $content .= '<p class="image">Height: '.$height.' pixels</p>'; $content .= '<p class="image">Filesize: '.$file_size.'</p>'; $content .= '</div>'; From the above you will see that "$settings['uploadpath'].$file" is the upload folder and the filename. "$settings['uploadpath']" is variable. I would like to get the full http://www.mydomain.com/folder_name/folder_name/whatever/file_name.jpg" - essentially the full URL of the stored file. Thanks Quote Link to comment Share on other sites More sharing options...
rhodesa Posted July 15, 2009 Share Posted July 15, 2009 you will need another variable then.... <?php //Filesystem path to uploads $settings['uploadpath'] = '/full/path/to/uploads/dir/'; //URL Path to uploads $settings['uploadurl'] = '/folder_name/folder_name/whatever/'; ?> there is just no GOOD way to translate the filesystem path to a URL Quote Link to comment Share on other sites More sharing options...
Bricktop Posted July 15, 2009 Author Share Posted July 15, 2009 Thanks Aaron, I'm already doing the above, just wondered if there was a more "dynamic" way of achieving it. I just wonder how the popular image upload websites achieve the same result? Quote Link to comment Share on other sites More sharing options...
rhodesa Posted July 15, 2009 Share Posted July 15, 2009 they all have a separate variable. you will find the same thing on most CMS installs (like Joomla, etc). you could try to subtract the $_SERVER['DOCUMENT_ROOT'] from it, but i tend to keep stuff out of my web root and then use symlinks...so you will run into issues there Quote Link to comment 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.