html - PHP file upload returns empty file type -


i have simple upload image works on 1 page returns empty file name in page

   if (isset($_post['upload_img'])) {    $file_name = $http_post_files['img']['name'];    $random_digit=rand(0000000,9999999999);    $new_file_name=$random_digit.$file_name.'.jpg';    $path= "images/".$new_file_name;    echo"$file_name";     } 

and html form

<form role="form" action="" method="post" enctype="multipart/form-data">    <div class="form-group"> <label for="exampleinputfile">upload image</label> <input type="file" id="exampleinputfile" name="img"> </div>  <p><a href="">terms , conditions</a></p>  <button type="submit" class="btn btn-default btn-block" name="upload_img">upload    </button>  </form> 

any idea whats wrong?

thank in advance

try

$file_name = $_files['img']['name']; 

instead of

$file_name = $http_post_files['img']['name']; 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -