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> </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.
http://php.net/manual/en/features.file-upload.post-method.php
http://php.net/manual/en/function.chmod.php (setting folder/files permissions).
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
Post a Comment