Heres the code:
whenever I try to upload a file it runs sends this message:
That message is located in the final section of php code:
But I cant find the error, could someone have a look at it for me please?
help
PHP:
<?php
$startHTML="<body bgcolor=\"#CCCCCC\">
<title>Uploading</title>
<div align=\"center\">
<table width=\"200\" border=\"1\" cellpadding=\"1\" cellspacing=\"1\" bgcolor=\"#FFFFFF\">
<tr>
<td><p><span class=\"style1 style2\"><img src=\"Images/Banner.gif\" width=\"600\" height=\"200\" border=\"0\" usemap=\"#Map\"></span>
<map name=\"Map\">
<area shape=\"rect\" coords=\"231,47,287,92\" href=\"Search.php\">
<area shape=\"rect\" coords=\"297,49,350,92\" href=\"home.php\">
<area shape=\"rect\" coords=\"357,48,414,93\" href=\"terms.php\">
<area shape=\"rect\" coords=\"423,48,485,93\" href=\"contact.php\">
<area shape=\"rect\" coords=\"491,47,571,90\" href=\"http://1.myfreebulletinboard.com/index.php?http://1.myfreebulletinboard.com/index.php?mforum=picminder\">
</map>
</p>";
echo $startHTML;
// Where the file is going to be placed temporarly
$target_path = "/";
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
$_FILES['uploadedfile']['tmp_name']; // temp file
$target_path = "./uploads/";
$oldfile = basename($_FILES['uploadedfile']['name']);
// checking the extention
$ext = strrchr($_FILES['uploadedfile']['name'], '.');
if((!$ext==".gif")&&(!$ext==".zip")&&(!$ext==".jpg")&&(!$ext==".jpx")&&(!$ext==".jpe")&&(!$ext==".jpeg")&&(!$ext==".png")&&(!$ext==".bmp")&&(!$ext==".wmv")&&(!$ext==".avi")&&(!$ext==".mpg")&&(!$ext==".mov")&&(!$ext==".asf")&&(!$ext==".asx")&&(!$ext==".swf")&&(!$ext==".3g2")&&(!$ext==".mp4")&&(!$ext==".mp3")&&(!$ext==".wav")&&(!$ext==".mid")&&(!$ext==".gz")&&(!$ext==".arc")&&(!$ext==".arg")&&(!$ext==".czip")&&($ext==".doc")&&(!$ext==".xls")&&(!$ext==".mdb")&&(!$ext==".ppt")&&(!$ext==".txt")&&(!$ext==".rtf")){
echo "Dissallowed File Extension!";
echo "<p>Allowed extensions are .zip, .gif, .bmp, .jpg, .png, .wmv, .avi, .mpg, .mov, .asf, .asx, .swf, .3g2, .mp4, .mp3, .wav and .mid</p>";
die( "<p><a href=\"Home.php\">Try Again</a></p>");
}else if(($ext==".wmv") or ($ext==".avi") or ($ext==".mpg") or ($ext==".mov") or ($ext==".asf") or ($ext==".asx") or ($ext==".swf") or ($ext==".3g2") or ($ext==".mp4") or ($ext==".mp3") or ($ext==".wav") or ($ext==".mid")){
if($_FILES['uploadedfile']['size'] > 10485760){
echo "File too large!";
echo "Maximum size for this extension is 10MB";
die( "<p><a href=\"Home.php\">Try Again</a></p>");
}
}else if(($ext==".gif") or ($ext==".jpg") or ($ext==".jpx") or ($ext==".jpe") or ($ext==".jpeg") or ($ext==".png") or ($ext==".bmp")){
if($_FILES['uploadedfile']['size'] > 20971520){
echo "File too large!";
echo "Maximum size for this extension is 2MB";
die( "<p><a href=\"Home.php\">Try Again</a></p>");
}
}else if(($ext==".zip") or (!$ext==".arc") or (!$ext==".arg") or (!$ext==".czip")){
if($_FILES['uploadedfile']['size'] > 31457280){
echo "File too large!";
echo "Maximum size for this extension is 3MB";
die( "<p><a href=\"Home.php\">Try Again</a></p>");
}
}else if(($ext==".doc") or (!$ext==".xls") or (!$ext==".mdb") or (!$ext==".ppt")){
if($_FILES['uploadedfile']['size'] > 5242880){
echo "File too large!";
echo "Maximum size for this extension is 5MB";
die( "<p><a href=\"Home.php\">Try Again</a></p>");
}
}else if(($ext==".txt") or (!$ext==".rtf")){
if($_FILES['uploadedfile']['size'] > 1048576){
echo "File too large!";
echo "Maximum size for this extension is 5MB";
die( "<p><a href=\"Home.php\">Try Again</a></p>");
}
}
//new file name example for a profile image of a user
//Get the users ip.
$ip="";
global $_SERVER;
if ($_SERVER['HTTP_X_FORWARD_FOR']) //stupid proxies! :P
{
$ip = $_SERVER['HTTP_X_FORWARD_FOR']; //get there real ip hehe
}else {
$ip = $_SERVER['REMOTE_ADDR']; //they dont use a proxy :)
}
$newfile = Rand(1,9999999999) . "_" . $ip . "_" . $_FILES['uploadedfile']['name'];
// move the file to the final destination
$target_loc = $target_path . basename($newfile);
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_loc)) {
echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded";
echo "<p>To link to your file please use <b>http://www.picminder.net/uploads/". $newfile . "</b></p>";
echo "<p>To view your file please goto <b>http://www.picminder.net/uploads/browsefile.php?file=". $newfile . "</b></p>";
echo "<p>We reserve the right to delete any file on our server.</p>";
die( "<p><a href=\"home.php\">Upload Another</a></p>");
$endHTML = " </tr>
</table>
<p align=\"center\" class=\"style1 style2\"> </p>
</div>
</body>";
echo $endHTML;
} else{
echo "There was an error uploading the file, please try again!";
die( "<p><a href=\"home.php\">Try Again</a></p>");
$endHTML = " </tr>
</table>
<p align=\"center\" class=\"style1 style2\"> </p>
</div>
</body>";
echo $endHTML;
}
?>
whenever I try to upload a file it runs sends this message:
Code:
There was an error uploading the file, please try again!
That message is located in the final section of php code:
PHP:
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_loc)) {
echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded";
echo "<p>To link to your file please use <b>http://www.picminder.net/uploads/". $newfile . "</b></p>";
echo "<p>To view your file please goto <b>http://www.picminder.net/uploads/browsefile.php?file=". $newfile . "</b></p>";
echo "<p>We reserve the right to delete any file on our server.</p>";
die( "<p><a href=\"home.php\">Upload Another</a></p>");
$endHTML = " </tr>
</table>
<p align=\"center\" class=\"style1 style2\"> </p>
</div>
</body>";
echo $endHTML;
} else{
echo "There was an error uploading the file, please try again!";
die( "<p><a href=\"home.php\">Try Again</a></p>");
$endHTML = " </tr>
</table>
<p align=\"center\" class=\"style1 style2\"> </p>
</div>
</body>";
echo $endHTML;
}
But I cant find the error, could someone have a look at it for me please?
help







