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.

<?php
/***********************************INSERT************************************************/
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"];

            move_uploaded_file($_FILES["img"]["tmp_name"],$target_path);



}

?>


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

<table width="70%" height="30%" align="center">
<tr>
    <th>Choose Photo</th>
    <td><input type="file" name="img" id="file"></td>
</tr>
<tr>
<td><input type="submit" name="submit" value="POST" /></td>
</tr>
</table>
</form>
$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.

No,Even though I get same 500 internal server error..

What's in your error log?

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:

isset($_POST['submit'])

Or

$_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.

Try increase file execution time in php.ini

or

Check with max_upload_size in php.ini

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.