Jump to content

Archived

This topic is now archived and is closed to further replies.

gterre

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

Recommended Posts

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

[img]http://www.geocities.com/gpterre/images/forbidden404.jpg[/img]

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.