CodeIgniter Forums
File Upload Helper - absolute path vs relative path - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: File Upload Helper - absolute path vs relative path (/showthread.php?tid=15252)



File Upload Helper - absolute path vs relative path - El Forum - 01-29-2009

[eluser]joneslee[/eluser]
Hi there,

I am now learning how to use the file upload. As I've known, $uploaded_data['file_path'] is an absolute path. eg /www/dev_site/site/mooksrds/public_html/testing/. Is there any way to retrive just the relative path .eg /testing?

Many thanks,


File Upload Helper - absolute path vs relative path - El Forum - 01-29-2009

[eluser]LagniappeInternet[/eluser]
Code:
$relative_url = str_replace ( $_SERVER['DOCUMENT_ROOT'], "" , $uploaded_data[‘file_path’]  )

So if the upload was /www/dev_site/site/mooksrds/public_html/testing/
and the Doc root was /www/dev_site/site/mooksrds/public_html
$relative_url should = /testing/