website help

Alkesh

Golden Member
Jul 21, 2005
1,391
1
0
but i can't seem to let anyone upload to my file storage directory without prompting them for a username and password which i don't wnat to give out. how do i get around this?
 

ruffilb

Diamond Member
Feb 6, 2005
5,096
1
0
Baaaad idea.

I mean.... uh...

Post the admin information and I'll figure it out for you.

Nice avy btw :thumbsup:
 

minendo

Elite Member
Aug 31, 2001
35,560
22
81
Here's an easy to use php script.

<form action="<?php print($_SERVER["SCRIPT_URL"]); ?>" enctype="multipart/form-data" method="post">
<table>
<tr>
<td>File : </td>
<td><input name="file" type="file" /></td>
</tr>
<tr>
<td></td>
<td><input name="files" type="submit" value="Upload" /><input type="reset" value="Reset" /></td>
</tr>
</table>
</form>
<?php
include("get_file_extension.inc.php");
include("download_link.inc.php");

$dir = "files/"; // chmod to 777

if ($_POST["files"]) {
if (in_array(get_file_extension($_FILES["file"]["name"]), array("bmp", "BMP", "gif", "GIF", "jpe", "JPE", "jpeg", "JPEG", "jpg", "JPG", "png", "PNG"))) {
if (!file_exists($dir . $_FILES["file"]["name"])) {
if (copy($_FILES["file"]["tmp_name"], $dir . $_FILES["file"]["name"])) {
$file = $_FILES["file"]["name"];
$headers = "From: user@domain.com";
$host = gethostbyaddr($_SERVER["REMOTE_ADDR"]);
$ip = $_SERVER["REMOTE_ADDR"];
$subject = "File added on Domain.com"; // your webpage
$time = date("l d F Y @ H:i");
$to = "user@domain.com"; // your email
$message = "File: http://" . $_SERVER["HTTP_HOST"] . "/" . $dir . $file . "\r\nHost: " . $host . "\r\nIP: " . $ip . "\r\nTime: " . $time;
mail($to, $subject, $message, $headers);
}

else {
print("Failed to copy the file.<br /><br />\r\n");
}
}

else {
print("The file already exists.<br /><br />\r\n");
}
}

else {
print("Only image files are allowed.<br /><br />\r\n");
}
}

$count = 0;
$filesArray = array();
$handle = opendir("files/");

while ($file = readdir($handle)) {
if ($file != "." && $file != "..") {
$filesArray[$count] = $file;
$count++;
}
}

closedir($handle);
array_multisort($filesArray, SORT_ASC, SORT_REGULAR);

for ($i = 0; $i < $count; $i++) {
print(download_link(("/files/" . $filesArray[$i]), $filesArray[$i]));

I can send you the .zip if you'd like.