maestrodamuz Posted December 10, 2008 Share Posted December 10, 2008 Hi ladies and gentlemen..nice to be here. I have always wondered how I could achieve this. I have an upload script to upload a file to a server, but I also want a field on a form to capture the file name and extention at the end of the URL string to submit to a database e.g C:/My Documents/Pictures/boy.jpg I want a field to capture just the boy.jpg part to submit to a datbase. Any help will be useful Link to comment https://forums.phpfreaks.com/topic/136412-how-do-i-copy-just-the-file-last-characters-in-a-url-string/ Share on other sites More sharing options...
trq Posted December 10, 2008 Share Posted December 10, 2008 Firstly.... C:/My Documents/Pictures/boy.jpg is a filesystem path, not a url. Now, to get just the boy.jpg part. echo basename('C:/My Documents/Pictures/boy.jpg'); Link to comment https://forums.phpfreaks.com/topic/136412-how-do-i-copy-just-the-file-last-characters-in-a-url-string/#findComment-711814 Share on other sites More sharing options...
Brian W Posted December 10, 2008 Share Posted December 10, 2008 get the file name into a string and use it like $string = basename($filename); header('location: page.php?file='.$string); Link to comment https://forums.phpfreaks.com/topic/136412-how-do-i-copy-just-the-file-last-characters-in-a-url-string/#findComment-711817 Share on other sites More sharing options...
maestrodamuz Posted December 10, 2008 Author Share Posted December 10, 2008 I am so going to enjoy this place...thank you Thorpe and Brian...let me go try your suggestions. Link to comment https://forums.phpfreaks.com/topic/136412-how-do-i-copy-just-the-file-last-characters-in-a-url-string/#findComment-711867 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.