Jump to content

simple idea for a php script...


kobayashi_one

Recommended Posts

Hi,
I want to make a site where you can add flash applets. For this I need to simple codes, but I'm a PHP newbie, so I need some help.
1: I need a code producing a link list of all files in a directory on my server.
2: I need a code that makes a form where you can enter the flash applet url, flash applet name, a applet catergory (example: Movies), and where you can add a link to the creator of the applet. When you submit this form, a website should be created with the applet in the specific category/directory.

I don't know how to make these codes.. has someone got the codes I need?
Link to comment
Share on other sites

  • 3 weeks later...
Hey bud, try this code for listing the files in your directory. Hope it works for you. I put some comments in to help you sort out what is happening. You should just be able to copy and paste this code into your web page.

Scot McConnaughay

<?php
// current directory
$root = "." ;
// set mydir as the current directory
$mydir = opendir($root);
// loop until the directory is empty
while(false !== ($file = readdir($mydir))){
// put each file into an array
if(!is_dir($file)){
$fileList[] = $file;
}
}
closedir($mydir);

natsort($fileList);

// set up the variable for displaying the list
$display = "data=";
// seperate each file in the list with a '#' sign
foreach($fileList as $file){
$display .= urlencode($file)."#";
}
// output the resulting list.
echo $display;
?>
Link to comment
Share on other sites

  • 1 month later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.