Jump to content


Photo

Forbidden 404 error file upload / unable to load phpfreaks.com


  • Please log in to reply
2 replies to this topic

#1 gterre

gterre
  • Members
  • PipPip
  • Member
  • 27 posts

Posted 23 August 2006 - 10:00 PM

I am trying to successfuly run a file upload script, however when i press the submit button, I get the following error

Posted Image

my code is as follows:

<?php
$maxsize=28480; //set the max upload size in bytes
if (!$HTTP_POST_VARS['submit']) {
  //print_r($HTTP_POST_FILES);
  $error=" ";
//this will cause the rest of the processing to be skipped
//and the upload form displays
}
if (!is_uploaded_file($HTTP_POST_FILES['upload_file']['tmp_name']) AND
!isset($error)) {
  $error = "<b>You must upload a file!</b><br><br>";
  unlink($HTTP_POST_FILES['upload_file']['tmp_name']);
}
if ($HTTP_POST_FILES['upload_file']['size'] > $maxsize AND !isset($error)) {
  $error = "<b>Error, file must be less than $maxsize bytes.</b><br><br>";
  unlink($HTTP_POST_FILES['upload_file']['tmp_name']);
}
if($HTTP_POST_FILES['upload_file']['type'] != "image/gif" AND
$HTTP_POST_FILES['upload_file']['type'] != "image/pjpeg" AND
$HTTP_POST_FILES['upload_file']['type'] !="image/jpeg" AND !isset($error)) {
  $error = "<b>You may only upload .gif or .jpeg files.</b><br><br>";
  unlink($HTTP_POST_FILES['upload_file']['tmp_name']);
}
if (!isset($error)) {
copy($HTTP_POST_FILES['upload_file']['tmp_name'],"uploads/".$HTTP_POST_FILES
['upload_file']['name']);
  unlink($HTTP_POST_FILES['upload_file']['tmp_name']);
  print "Thank you for your upload.";
  exit;
}
else
{
  echo ("$error");
}
?>

<html>
<head></head>
<body>
<form action="<?=$PHP_SELF?>" method="post" enctype="multipart/form-data">
Choose a file to upload:<br>
<input type="file" name="upload_file" size="40">
<br>
<input type="submit" name="submit" value="submit">
</form>
</body>
</html>



Also on another note, I cannot access phpfreaks.com or any of its directory pages.. All i get is a blank page, and this is on the computer that i installed wamp on which has php mysql and apache on it. can someone please help me with this because it is a pain transfering information from on computer to another just to request for help on this forum. thanks.

#2 hitman6003

hitman6003
  • Members
  • PipPipPip
  • Advanced Member
  • 1,807 posts

Posted 23 August 2006 - 10:04 PM

change:

<?=$PHP_SELF?>

to:

<?php echo $_SERVER['PHP_SELF']; ?>


#3 gterre

gterre
  • Members
  • PipPip
  • Member
  • 27 posts

Posted 23 August 2006 - 10:11 PM

Thank you soooooo much, it worked :)

now i just need help in viewing phpfreaks.com / I have no idea why i'm not able to view it on my computer.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users