midnight123 Posted September 26, 2007 Share Posted September 26, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/70704-invalid-file-upload-on-webserver/ Share on other sites More sharing options...
midnight123 Posted September 26, 2007 Author Share Posted September 26, 2007 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? Quote Link to comment https://forums.phpfreaks.com/topic/70704-invalid-file-upload-on-webserver/#findComment-355444 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.