Jump to content

Uploading images to the database


suhaib
 Share

Recommended Posts

I need it to be uploaded to the database. Do you know how to fix it ? Because when I uploaded image show it error massageI need it to be uploaded to the database. Do you know how to fix it ? Because when I uploaded image show it error massage

 

      $title = $_POST['title'];

        $info = $_POST['info'];

        $text = $_POST['text'];

        // varabls Uploud

        $imgssName = $_FILES['img']['name'];

        $imgSize = $_FILES['img']['size'];

        $imgTmp = $_FILES['img']['tmp_name'];

        $imgType = $_FILES['img']['type'];

 

        // Chek extensions Img

        $file_parts = pathinfo($imgssName);

 

        $file_parts['extension'];

        $cool_extensions = Array('jpeg', 'jpg', 'JPG', 'png', 'PNG', 'gif', 'JPEG', 'GIF', 'pdf','psd');

        if (in_array($file_parts['extension'], $cool_extensions)){

        // Chek Size Img

        $img = rand(0, 100000000) . '_' . $imgssName;

        move_uploaded_file($imgTmp, "uploads/imgs//" . $img);

        $stmt = $con->prepare("INSERT INTO 

                    news(title,info,text,img,date) VALUES (:btitle, :binfo, :btext, :bimg, now()  )");

        $stmt->execute(array(

                        'btitle' => $title,

                        'binfo' => $info,

                        'btext' => $text,

                        'bimg' => $img,

                        

                            ));

 

?

Edited by cyberRobot
Moved question / description into the message body
Link to comment
Share on other sites


Warning: Undefined array key "img" in C:\xampp\htdocs\suhaib1\admin\insert-news.php on line 17

Warning: Trying to access array offset on value of type null in C:\xampp\htdocs\suhaib1\admin\insert-news.php on line 17

Warning: Undefined array key "img" in C:\xampp\htdocs\suhaib1\admin\insert-news.php on line 18

Warning: Trying to access array offset on value of type null in C:\xampp\htdocs\suhaib1\admin\insert-news.php on line 18

Warning: Undefined array key "img" in C:\xampp\htdocs\suhaib1\admin\insert-news.php on line 19

Warning: Trying to access array offset on value of type null in C:\xampp\htdocs\suhaib1\admin\insert-news.php on line 19

Warning: Undefined array key "img" in C:\xampp\htdocs\suhaib1\admin\insert-news.php on line 20

Warning: Trying to access array offset on value of type null in C:\xampp\htdocs\suhaib1\admin\insert-news.php on line 20

Warning: Undefined array key "extension" in C:\xampp\htdocs\suhaib1\admin\insert-news.php on line 26

Warning: Undefined array key "extension" in C:\xampp\htdocs\suhaib1\admin\insert-news.php on line 29
الصورة غير معرفه

Link to comment
Share on other sites

  • cyberRobot changed the title to Uploading images to the database

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.