How to upload image and save path to database?

前端 未结 2 910
梦如初夏
梦如初夏 2021-01-28 01:20

I have a page where some images are shown (database driven). Here is the code of my gallery.php :

2条回答
  •  孤独总比滥情好
    2021-01-28 02:05

    After some hours I found a solution. It works. Although I would still be happy to find a second solution (according to the code I first posted here). Here is the second solution :

    form page :

    insert to database page :

     0)
      {
         echo "Error: NO CHOSEN FILE 
    "; echo"

    INSERT TO DATABASE FAILED"; } else { move_uploaded_file($_FILES["image"]["tmp_name"],"images/" . $_FILES["image"]["name"]); echo"SAVED
    "; $file="images/".$_FILES["image"]["name"]; $sql="INSERT INTO eikones (auxon, path) VALUES ('','$file')"; if (!mysql_query($sql)) { die('Error: ' . mysql_error()); } echo "SAVED TO DATABASE"; } mysql_close(); ?>

提交回复
热议问题