I have looked at a heap of upload scripts on here and on alltheweb.com and as yet I have not found a solution.
I have done a upload script for members to upload wav and midi files, but at the moment I am having problems with the files.
What I am trying to do is strip the file path and just keep the name.
At the moment my script adds everything into the database and naturally that is going to cause a broken link when another member goes to preview the wav or midi file.
At the moment C:\blah\blah\sample.wav is being entered into the datanbase and I am trying to remove the c:\blah\blah\ and just have sample.wav edded to the database.
Anyone have any ideas on how to do this?
I have tried temp name, new name, but could not get it to work.
Ta muchly.
Strip Path
Started by _*Creative Insanity_*, Mar 10 2007 02:33 PM
4 replies to this topic
#1 _*Creative Insanity_*
Posted 10 March 2007 - 02:33 PM
#2
Posted 10 March 2007 - 02:59 PM
Best idea is to explode the file path/name using the slash as the delimiter and grab the last section, e.g...
Matt
$explode = explode('\', $file);
$filename = $explode[count($explode)];
Matt
#3 _*Creative Insanity_*
Posted 10 March 2007 - 03:15 PM
Ah huh! Thanks a million Matthew.. now why did this silly old bugger not think of that.
Worked a treat. Thanks heaps.
Worked a treat. Thanks heaps.
#4
Posted 10 March 2007 - 08:08 PM
... or basename();
// home/user/public_html/basename.php echo basename(__FILE__); // basename.php
Edited by SecondV, 10 March 2007 - 08:08 PM.
#5
Posted 10 March 2007 - 09:21 PM
SecondV, on Mar 11 2007, 01:08 AM, said:
... or basename();
// home/user/public_html/basename.php echo basename(__FILE__); // basename.php
Having said that using my method with linux structure would cause the same problems.
Matt
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users
