Upload file names from dir

Hi, i need to upload only file names from directory and directory name. I have table with name “box” in box have “sound” - varchar when need to put file name and “dir” - varchar when need to put dir name.
directory name and file name can have cyrillic or others simbols.

example : dir : in C:\mp3 have : 1.mp3; 2.mp3; 3.mp3 … n.mp3
i want to upload my database like this:

sound dir
1.mp3 C:\mp3
2.mp3 C:\mp3
3.mp3 C:\mp3


n.mp3 C:\mp3

Some one can help me ?

Well, you can do it something like this:

 $dir = "mp3";
 $files = scandir($dir);
 foreach($files as $filename) {
     echo $dir."/".$filename . "<br>";   // Handle filename here... 
 }

If you need to save both the path and filename into a database, you can just edit it as you wish and save it into a field. Normally you would not save it backwards as you showed, meaning filename then foldername. You normally would save it as it is with a forward slash between them.
Hope this helps

1 Like
Sponsor our Newsletter | Privacy Policy | Terms of Service