PHP image upload fail -


i need help. trying upload image php code. when use different .php file upload code, works, when try add main code have information posted database.

i have added , said works separate code upload.

form action="core/books-reg.php" method="post" enctype="multipart/form-data" 

this main .php code in want make work. code starts after !empty(description). database takes name , puts in mysql there no file in folder. or other method good.

<?php session_start();  require("dbc.php");  $username = $_session['username']; $title = $_post['title']; $con = $_post['con']; $price = $_post['price']; $prodcode = $_post['prodcode']; $isbn = $_post['isbn']; $publisher = $_post['publisher']; $pages = $_post['pages']; $description = $_post['description']; $year = $_post['year']; $course = $_post['course']; $module = $_post['module'];  if(!empty($title)) {     if(!empty($price))     {         if(!empty($prodcode))         {             if(!empty($isbn))             {                 if(!empty($publisher))                 {                     if(!empty($pages))                     {                         if(!empty($description))                         {                             if (!isset($_files['image']['tmp_name'])) {                             echo "";                             }else{                             $file=$_files['image']['tmp_name'];                             $image= addslashes(file_get_contents($_files['image']['tmp_name']));                             $image_name= addslashes($_files['image']['name']);                              move_uploaded_file($_files["image"]["tmp_name"],"upload/" . $_files["image"]["name"]);                              $location="upload/" . $_files["image"]["name"];                                          }                              mysql_query("insert `books` (username,title,con,price,prodcode,isbn,publisher,pages,description,image,year,course,module) values('$username','$title','$con','$price','$prodcode','$isbn','$publisher','$pages','$description','$image_name','$year','$course','$module')");                             header("location: ../add_books.php?feedback=your book has been put on books page.");                         }                         else                         {                             header("location: ../add_books.php?feedback=description field empty");                         }                     }                     else                     {                         header("location: ../add_books.php?feedback=pages field empty");                     }                 }                 else                 {                     header("location: ../add_books.php?feedback=publisher field empty");                 }             }             else             {                 header("location: ../add_books.php?feedback=isbn field empty");             }         }         else         {             header("location: ../add_books.php?feedback=product code field empty");         }     }     else     {         header("location: ../add_books.php?feedback=price field empty");     } } else {     header("location: ../add_books.php?feedback=title field empty"); }    ?> 

if u want place upload code on same page firstly don't need specify action in form tag.

and check path upload/ @ correct place exists or not.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -