Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Browsing files using PHP
Old 11-08-2006, 06:43 AM Browsing files using PHP
Novice Talker

Posts: 7
Trades: 0
Hello i am pretty much brand new to PHP and MySQL and i need some help setting up an application in PHP than can browse my linux computer for all .mp3 files and will display them and allow them to be available for download from anyone who visits the web page...can anyone help?
Spicecube914 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 11-08-2006, 07:20 AM Re: Browsing files using PHP
kreoton's Avatar
Extreme Talker

Posts: 194
Trades: 0
Use this http://lt.php.net/manual/en/function.scandir.php function
__________________

Please login or register to view this content. Registration is FREE
|

Please login or register to view this content. Registration is FREE
kreoton is offline
Reply With Quote
View Public Profile Visit kreoton's homepage!
 
Old 11-08-2006, 12:26 PM Re: Browsing files using PHP
Novice Talker

Posts: 7
Trades: 0
awesome thank you very much....is there any way i can use that to search for only one type of file...like can i impliment something like scandir(*.php) or something and have it out put only one file type?
Spicecube914 is offline
Reply With Quote
View Public Profile
 
Old 11-08-2006, 07:05 PM Re: Browsing files using PHP
kreoton's Avatar
Extreme Talker

Posts: 194
Trades: 0
no there is no function ike you wish
__________________

Please login or register to view this content. Registration is FREE
|

Please login or register to view this content. Registration is FREE
kreoton is offline
Reply With Quote
View Public Profile Visit kreoton's homepage!
 
Old 11-08-2006, 07:38 PM Re: Browsing files using PHP
Novice Talker

Posts: 7
Trades: 0
ok thank you very much
Spicecube914 is offline
Reply With Quote
View Public Profile
 
Old 11-08-2006, 10:55 PM Re: Browsing files using PHP
Novice Talker

Posts: 7
Trades: 0
oh and i had one more question......how do create a link to download a file you find in a directory...say you find an mp3 file and you want to allow viewers to be able to download that file...how would you do it?
Spicecube914 is offline
Reply With Quote
View Public Profile
 
Old 11-09-2006, 05:44 AM Re: Browsing files using PHP
kreoton's Avatar
Extreme Talker

Posts: 194
Trades: 0
Quote:
Originally Posted by Spicecube914 View Post
oh and i had one more question......how do create a link to download a file you find in a directory...say you find an mp3 file and you want to allow viewers to be able to download that file...how would you do it?

simply

lets say i fave all file names in array $mp3_files;

PHP Code:

foreach ($mp3_file as $file) {
   echo 
'<a href="path/to/mp3/files/dir/'.$file.'">'.$file.'</a><br />';

__________________

Please login or register to view this content. Registration is FREE
|

Please login or register to view this content. Registration is FREE
kreoton is offline
Reply With Quote
View Public Profile Visit kreoton's homepage!
 
Old 11-09-2006, 10:01 AM Re: Browsing files using PHP
Novice Talker

Posts: 7
Trades: 0
awesome again!.....this question is kind of away from php but when it prints out the files it gives me all the album art and thumbs and stuff....do you know how to delete those?
Spicecube914 is offline
Reply With Quote
View Public Profile
 
Old 11-09-2006, 10:06 AM Re: Browsing files using PHP
kreoton's Avatar
Extreme Talker

Posts: 194
Trades: 0
Quote:
Originally Posted by Spicecube914 View Post
awesome again!.....this question is kind of away from php but when it prints out the files it gives me all the album art and thumbs and stuff....do you know how to delete those?
you do not have to delete files, just filter filelist

PHP Code:
foreach ($mp3_file as $file) {
    if (
eregi('.mp3$'$file)) {
        echo 
'<a href="path/to/mp3/files/dir/'.$file.'">'.$file.'</a><br />';
    }

__________________

Please login or register to view this content. Registration is FREE
|

Please login or register to view this content. Registration is FREE
kreoton is offline
Reply With Quote
View Public Profile Visit kreoton's homepage!
 
Old 11-10-2006, 03:28 AM Re: Browsing files using PHP
Novice Talker

Posts: 7
Trades: 0
wow thank you very much...im sure i will have more questions so please keep an eye out here
Spicecube914 is offline
Reply With Quote
View Public Profile
 
Old 11-17-2006, 12:47 AM Re: Browsing files using PHP
Skilled Talker

Posts: 67
Location: Erin, NY
Trades: 0
I want to do somehting like this... Heres what I got going on.

I'm doing a linux how-to site. (never enough how-to sites )

Each how-to is in html format. they are named like this Athlon-Powersaving-HOWTO.html

What I would like to happen is for php to look in the how-to dir and list them on a page is alphabetical order while stripping part of the name off them.

So it would look like this.

Code:
ACPI
ADSL-Bandwidth-Management
ADSM
AI-Alife
ATA-RAID
ATM-Linux
AX25
instead of this

Code:
ACPI-HOWTO.html 
ADSL-Bandwidth-Management-HOWTO.html 
ADSM-Backup.html 
AI-Alife-HOWTO.html 
ATA-RAID-HOWTO.html 
ATM-Linux-HOWTO.html 
AX25-HOWTO.html
and I want them all to be links. and when you click on them it will open them in a new window.

Can someone show me how to do this?
ltcjohnson is offline
Reply With Quote
View Public Profile Visit ltcjohnson's homepage!
 
Old 11-17-2006, 02:30 AM Re: Browsing files using PHP
kreoton's Avatar
Extreme Talker

Posts: 194
Trades: 0
PHP Code:
//lets say you have all files in $files array

foreach ($files as $file) {
    
//explode file in temp array
    
$tmp explode('HOWTO'$file);
    
//now we have $tmp array that containts $tmp = array(0=>'ACPI-', 1=>'.html') so we just need to remove (-) symbol
    
$link_name substr($tmp[0], 0, -1);
    
$links_array '<a href="'.$file.'">'.$link_name.'</a>';

__________________

Please login or register to view this content. Registration is FREE
|

Please login or register to view this content. Registration is FREE
kreoton is offline
Reply With Quote
View Public Profile Visit kreoton's homepage!
 
Old 11-22-2006, 07:53 AM Re: Browsing files using PHP
Novice Talker

Posts: 7
Trades: 0
Hey im back with a couple questions...first of all i want to k now how to change the working directory of the apache web server...im using windows xp if that matters....and i also want to know how to make a configuration file....so if i want to share my mp3 download script, the user can change the directory that the files will be in...thanks
Spicecube914 is offline
Reply With Quote
View Public Profile
 
Old 06-14-2007, 02:08 PM Re: Browsing files using PHP
Skilled Talker

Latest Blog Post:
My book update
Posts: 97
Name: Eric
Location: Las Vegas
Trades: 0
this is the change directory function
chdir('dir_name');
__________________

Please login or register to view this content. Registration is FREE

Eric - M
Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
peanutpad is offline
Reply With Quote
View Public Profile Visit peanutpad's homepage!
 
Reply     « Reply to Browsing files using PHP
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.65671 seconds with 12 queries