Jump to content

Get URL of uploaded file


Bricktop

Recommended Posts

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

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.