Jump to content

Get URL of uploaded file


Bricktop

Recommended Posts

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

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.