OKay pretty new to php coding decided wanted to make my OWN upload, directory lsiting/ viewing script, did all that, then made a quick script to go with the bundle that viewed the Uploads folder where the uploads.php script uploaded to!
Jsut quick web server info,
Windows XP running Apache 1.3.26 with Php 5.0.0.0 .
I know lol Windows, its just a test server.
Anywayz
http://mysite/fserve/index.php < main script
http://mysite/fserve/upload_view.php < script im talking about
upload_view.php is looking at a folder located @ http://mysite/fserve/Uploads/
whole site requiresd authetnication access using .htaccess password, the /fserve/ folder is locked down so u cant bring a directory listing of it and so on.
Now here is my upload_view.php script,
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>ridbc phpupload 0.5</title>
</head>
<body>
<div align="center"><font size="1" face="Verdana">
<?php
function display_size($file_size){
if($file_size >= 1073741824) {
$file_size = round($file_size / 1073741824 * 100) / 100 . "g";
} elseif($file_size >= 1048576) {
$file_size = round($file_size / 1048576 * 100) / 100 . "m";
} elseif($file_size >= 1024) {
$file_size = round($file_size / 1024 * 100) / 100 . "k";
} else {
$file_size = $file_size . "b";
}
return $file_size;
}
$filesize = display_size(filesize($file));
if ($_REQUEST['delete'] == "yes")
{
if ($_REQUEST['con'] == "yes") {
unlink("$filedir/$file");
echo "$filedir/$file has been deleted. Click <a href=\"upload.php\">here</a> to return.";
exit;
} else {
echo "Are you sure you want to delete $filedir/$file?<br>";
echo "Click <a href=\"$PHP_SELF?delete=yes&file=$file&con=yes&filedir=$filedir\">here</a> to confirm your request.";
exit;
}
}
include("upload_config.php");
$the_path= $filedir;
if(!file_exists($the_path)) {
$a="";
foreach(explode("/",$the_path) AS $k) {
$a.=$k."/";
if(!file_exists($a)) mkdir($a, 0777);
}
}
$dh = opendir($filedir);
echo "Directory Listing of $filedir/<br><br>";
while(gettype($file = readdir($dh)) != boolean)
{
if (is_dir("$filedir/$file")) {
echo "(Directory) <a href=\"$filedir/$file\">$file</a><br><br>";
} else {
echo "» ";
echo "<a href=\"$filedir/$file\">$file</a> - <a href=\"$PHP_SELF?delete=yes&file=$file&filedir=$filedir\">delete?</a><br>";
print "File Size: ".display_size(filesize($file))."";
print "Last accessed: ".date("D d M Y g:i A", fileatime($file))." - ";
print "Last modified: ".date("D d M Y g:i A", filemtime($file))." - ";
print "Last changed: ".date("D d M Y g:i A", filectime($file))." ";
echo "<br><br>";
}
}
closedir($dh);
?>
</font><font size="1" face="Verdana"><b><br>
<br>
<br>
<font face="Geneva, Arial, Helvetica, sans-serif">ridbc phpupload 0.5</font></b></font>
<font size="1" face="Geneva, Arial, Helvetica, sans-serif"><a href="mailto:email hereorg.au"><br>
contact</a></font></div>
</body>
</html>
Now when i run that, it should show say tehres file in the Uploads directory called logo.gif,
logo.gif
File Size: 100k
Last modified: 10 Sep etc etc
last access: etc etc
But when i run it, it does the following,
Warning: filesize() [function.filesize]: stat failed for logo.gif in c:\program files\apache group\Apache\htdocs\fserve\upload_view.php on line 60
File Size: b
Warning: fileatime() [function.fileatime]: stat failed for logo.gif in c:\program files\apache group\Apache\htdocs\fserve\upload_view.php on line 61
Last accessed: Thu 01 Jan 1970 11:00 AM -
Warning: filemtime() [function.filemtime]: stat failed for logo.gif in c:\program files\apache group\Apache\htdocs\fserve\upload_view.php on line 62
Last modified: Thu 01 Jan 1970 11:00 AM -
Warning: filectime() [function.filectime]: stat failed for logo.gif in c:\program files\apache group\Apache\htdocs\fserve\upload_view.php on line 63
Last changed: Thu 01 Jan 1970 11:00 AM
But when i modfiy script and put it IN the uplaods directory everything works. So i assumed permissions, now i know how to cahnge permission for scripts, files, n shit using chmod via ftp normally but on my own pc with windows i had no clue so i just made sure everyoen could access etc etc, i also shared the Uplaods folder thinking taht might change permissions to allow it. None of this helped, was wondering if anyone had any ideas?
Cheers,
Ry