Jump to content

Invalid file upload on webserver


midnight123

Recommended Posts

I ran these pages on my computer using an apache server and everything is working fine.When I uploaded them to a webserver I am getting

an 'invalid file' message when I try to upload.

 

 

 

 

<html<body><br><br><br><center>

<form enctype="multipart/form-data" action="uploader.php" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="100000" />
Choose a file to upload: <input name="uploadedfile" type="file" /><br />
<input type="submit" value="Upload File" />
</form></center>
</body>
</html>

 

 

 

<html><body><br><br><br><center>

<?php


     if ($_FILES['uploadedfile']['type']=="image/jpeg")
{




include("function_index.php"); 

echo("<br>");

$target_path = "uploads/";

  
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']); 
$_FILES['uploadedfile']['tmp_name'];  
$newname=randomvalue();

$target_path = "uploads/";
$_FILES['uploadedfile']['name']=$newname;
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']); 

if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
    echo "Uploaded file";
echo("<center>");
echo("<IMG SRC='uploads/$newname'>");
echo("</center>");  
list($width, $height, $type, $attr) = getimagesize("uploads/".$newname);

echo("<br><center>");
  $size=$height * $width;
  echo("Pixal size : ");
  echo($size);
  echo("</center><br>");
     echo("<center>");
echo("Click on the grid below to place your image");
echo("</center>"); 

  echo("<form action='Imageset.php' method='post'>"); 
  echo("<center><INPUT id='initimage' type='hidden' value=$newname  name='initimage' ></center>");
echo("<input type='image' src='uploads/grid.jpg' name='mpos' id='mpos'value='' />");

  echo("</form>");
   
} else{
    echo "There was an error uploading the file, please try again!";
}

}

else
{
echo("<center>Invalid file upload</center>");

}
?>
</center></body></html>

 

 

I tried changing permissions to 0777 on the two pages but got this,no

doubt because there is no jpg.

 

 

Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, webmaster@pizad.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.


Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request. 


--------------------------------------------------------------------------------


and this is the log error?


Apache/1.3.37 Server at pizad.com Port 80

 

[Wed Sep 26 09:53:55 2007] [error] [client 76.68.37.119] File does not exist: /home/add15858/public_html/500.shtml
[Wed Sep 26 09:53:55 2007] [error] [client 76.68.37.119] Premature end of script headers: /home/add15858/public_html/uploader.php

 

 

I wonder why I'm geting an inavald fileupload for a jpg.As I say it works fine on my computer but not on the server.

Link to comment
Share on other sites

  I changed:

  if ($_FILES['uploadedfile']['name'])

    //if ($_FILES['uploadedfile']['type']=="image/jpeg")

{

  I did this so it wouldn't check the filetype and it's

uploading fine.The thing is this would only allow a jpeg

to be uploaded on the apache server on my computer

but messed up on the webserver not allowing any uploads.

Why is this?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.