move_uploaded_file gives

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator to inform of the time the error occurred and of anything you might have done that may have caused the error.

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

if($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['submit']) == 'POST'){

            $valid_formats = array("jpg", "png", "gif", "bmp"); 
            $name = $_FILES["img"]["name"];
            $size = $_FILES["img"]["size"];
            //$temp = explode(".",$name);     
            //$ext = end($temp);            

           $target ="/uploads/$_FILES["img"]["tmp_name"];




<form role="form" method="post" action="clients.php" enctype="multipart/form-data">

<table width="70%" height="30%" align="center">
    <th>Choose Photo</th>
    <td><input type="file" name="img" id="file"></td>
<td><input type="submit" name="submit" value="POST" /></td>

Edited by chaitu11

4 Years
Discussion Span
Last Post by suresh9696
$target ="/uploads/$_FILES["img"]["tmp_name"]; // line 15

should be:

$target = "/uploads/" . $_FILES["img"]["tmp_name"];

and on line 17 $target_path should be $target I think.


Just a note but your if statement has an error.

if($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['submit']) == 'POST')

You're checking if a variable is set and then if the result is POST. You will need either:



$_POST['submit'] == 'POST'

My recommendation would be the first.

The isset(); function can only return either TRUE or FALSE but you are checking to see if it has the value of POST. By just having isset($_POST['submit']) in the if statement, you are checking to see if it is set to TRUE. To check if it is false, you would change it to !isset($_POST['submit']).

The error log will be more precise as to the cause of the 500 error message. I don't think the error in the if statement would have caused a 500 error.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.