it's not the whole script...
i wrote new script but it doesnt work too...
here it is and this time it's the whole:
PHP Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<META content="text/html; charset=windows-1255" http-equiv=Content-Type>
<title>NEOPROJECTS</title>
</head>
<body>
<?php
include('config.php');
$limitedext = array(".gif",".jpg",".png",".jpeg",".bmp");
if (!is_writeable($bdir)){
die ("Error: The directory <b>($bdir)</b> is NOT writable");
}
$size = $canup/1024/1024;
$rand_dir = rand(100000, 999999);
$mkdir = $bdir."/".$rand_dir."/";
echo "[<b>".$size." MB</b>]<br>";
echo "<form enctype=\"multipart/form-data\" method=\"post\" action=\"?action=upload\">
<input type=\"file\" name=\"userfile\">
<br>
<input type=submit name=submit value=Send></form>";
if($_GET['action'] == 'upload')
{
$file_type = $_FILES['userfile']['type'];
$file_name = $_FILES['userfile']['name'];
$file_name = str_replace(" ", "", $file_name);
$file_name = strtolower($file_name);
$file_size = $_FILES['userfile']['size'];
$file_tmp = $_FILES['userfile']['tmp_name'];
$ext = strrchr($file_name,'.');
$ext = str_replace(" ", "", $ext);
$ext = strtolower($ext);
if(!is_uploaded_file($file_tmp))
{
echo "Error: Please select a file to upload!";
exit();
}
if (($extlimit == "yes") && (!in_array($ext,$limitedext)))
{
echo "Error: Wrong file extension";
exit();
}
$rand_name = rand(10, 99);
if($file_size == 0)
{
echo "Error: File size is 0";
exit();
}
if($file_size == $canup || $file_size > $canup)
{
echo "Error: File size is bigger than <b>".$size." MB</b>";
exit();
}
mkdir($mkdir) or die ("Directory could not be created.");
chmod($mkdir, 0777) or die ("Directory could not be CHMOD.");
$mkdir = $mkdir.$rand_name.$file_name;
if (move_uploaded_file($file_tmp, $mkdir))
{
echo "Direct link <input type=text size=45 onFocus=\"this.select()\" value=".$url.$mkdir.">";
echo "<br>Forums link <input type=text size=45 onFocus=\"this.select()\" value=[IMG]".$url.$mkdir."[/IMG]>";
} else {
echo "Error: A problem occurred while trying to upload the file";
exit();
}
}
?>
<br>
<a href="http://validator.w3.org/check?uri=referer"><img
src="http://www.w3.org/Icons/valid-html401"
alt="Valid HTML 4.01 Transitional" height="31" width="88" border="0"></a>
</body>
</html>
this is the config.php :
PHP Code:
<?
$url='http://eyal.webkit.biz/MsU/';
$bdir='imgs';
$canup='5242880';
$extlimit='yes';
?>
BTW
The script works good if i give it a specific directory and not a random.
the idea is to create a random directory and upload the file to it
Bookmarks