Decaflon

Welcome to Decaflon! Where the geeks hang out: Signup or Login Here
Decaflon is proudly hosted by (mt) Media Temple.  We recommend them for your web hosting needs.
Clips: Popular Clips Upcoming Clips Notes: All Notes

Hey 9rules people!
I am on the look-out for some scripts I need for a small project.

1. I need a directory script, I need to be able to point the script at a folder and be able to list the directory in another file. Ex: Directory is viewed in the root, but it is showing the files located in /files/

(if the above script has a feature that will allow me to password protect the file you have hit the jackpot, idealy)

2. A uploading script, that I can point to the /files/ folder.

PHP btw. Thanks alot any tips and i'm in yor dept.

-Phiip

Nobody? I just need the index scrit now.

Let's see if this works...

    <?php
    if ($handle = opendir($_SERVER['DOCUMENT_ROOT'].'/files')) {
    while (false !== ($file = readdir($handle))) {
    if (
    $file != "." &&
    $file != ".."
    ) {
    $lastmodified = filemtime($file);
    echo '
  • '.$file.' '.'
  • '."\n";
    }
    }
    }
    ?>

crap it didn't... hold on...

    <?php
    if ($handle = opendir($_SERVER['DOCUMENT_ROOT'].'/files')) {
    while (false !== ($file = readdir($handle))) {
    if (
    $file != "." &&
    $file != ".."
    ) {
    $lastmodified = filemtime($file);
    echo '
  • '.$file.' '.'
  • '."\n";
    }
    }
    }
    ?>

9Rules formatting hates me...

replace '^^' with < or >

<?php
if ($handle = opendir($_SERVER['DOCUMENT_ROOT'].'/files')) {
while (false !== ($file = readdir($handle))) {
if (
$file != "." &&
$file != ".."
) {
$lastmodified = filemtime($file);
echo '^^a href="/files/'.$file.'/"^^'.$file.'^^/a^^'."\n";
}
}
}
?>

This is what I used, but since this only displays the title I will be changing this later, I would like all the specs to show, size, date.

<?php
$open = opendir("files/"); // Opens Folder
while(false !== ($read = readdir($open))) // Loops Through
if($read !== "error_log" && $read !== ".snifthumbs" && $read !== ".." && $read !== ".") // Removes unwanted files
print("<a href='files/$read'>$read</a><br />"); // Correct Linkage
?>

As for the file upload the html:

<form enctype="multipart/form-data" action="post.php" method="post">
<p>
<input type="hidden" name="MAX_FILE_SIZE" value="1048576" />
<input type="file" name="file" size="30" /><br />
<input type="submit" value="Upload" />
</p>
</form>

and post.php should have this in it:

$file = $_FILES['file'];
if($file['error'] != 0){
print "The file you tried to upload was to big.";
}elseif(file_exists("./files/".$file['name'])){
print "A file with that name already exists.";
}elseif(move_uploaded_file($file['tmp_name'], "./files/".$file['name'])){
print "File Uploaded";
}

Sorry if the formatting is all screwy

This is what I use.

<?php
$filenum = 5;
$file_dir = "DIRECOTRY - like /home2/steven/public_html/whsb/member/files/";
if ($_POST) {
?>
<script type="text/javascript">var f = document.getElementById('browsefiles'); f.src = f.src;</script>
<?php
for ($i=0;$i<$numoffile;$i++) {
if (trim($_FILES['myfiles']['name'][$i])!="") {
$newfile = $file_dir.$_FILES['myfiles']['name'][$i];
move_uploaded_file($_FILES['myfiles']['tmp_name'][$i], $newfile);
$j++;
}
}
}
if (isset($j)&&$j>0) echo "<strong>Uploaded!<br /></strong>";
echo "<form method='post' enctype='multipart/form-data'>";
for($i=0;$i<$filenum;$i++) {
echo "<input type='file' name='myfiles[]' size='40' /><br />";
}
echo "<input type='submit' name='action' value='Upload!' />";
echo "</form>";
?>

Please Login To Leave A Comment

Decaflon Sponsors Get in touch if you want in.

Hot Notes (View all »)

 

Decaflon is part of the Chawlk Network of sites.

9 Great Places To Visit, Hang Out, & Meet New People

What's new and interesting at other Chawlk Network sites: