html - Upload a file in folder using PHP script -


i trying upload , save image using php scripting, image not getting saved in specified folder. please help

here's code:

  <?php   if(isset($_post['button'])){   $name= "product_name.jpg";   move_uploaded_file($_files["filefield"]["tmp_name"],"student_images/$name");   header("location: tryupload.php");   }   ?>   <html>   <body>   <form action="tryupload.php" enctype="multiple/form-data" name="myform" id="myform" method="post">   <table>   <tr>     <td align="right">product image</td>     <td><label>       <input type="file" name="filefield" id="filefield" />     </label></td>   </tr>         <tr>     <td>&nbsp;</td>     <td><label>       <input type="submit" name="button" id="button"/>     </label></td>   </tr></table>   </form>   </body>   </html> 

this part of code enctype="multiple/form-data" incorrect.

it needs read enctype="multipart/form-data".

also make sure folder intend on uploading to, has proper permissions write to.

uploading security-related links:


add error reporting top of file(s) find errors.

<?php  error_reporting(e_all); ini_set('display_errors', 1);  // rest of code 

sidenote: error reporting should done in staging, , never production.


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -