I tried uploading the image and sending it to the database but it is not working. And when I try again on var_dump, this output is:
array (1) {["upload"] => Array (5) {["name"] = & gt; String (9) "error.jpg" ["type"] = & gt; String (10) "image / jpeg" ["tmp_name"] = & gt; String (24) "C: \ xampp \ tmp \ php8E94.tmp" ["Error"] = & gt; Int (0) ["size"] = & gt; Int (82805)}}
This is my code:
& lt ;? Php included (includes '/ config.php'); $ Mysqli = new mysqli (DB_SERVER, DB_UNAME, DB_PASSWD, DB_NAME); If ($ mysqli-> connect_errno) {echo "MYSQLI connect does not error {$ mysqli- & gt; connect_errno}: {$ mysqli-> Connect_error}"; Die (); } If (isset ($ _ POST ['addbtn'])) {$ itemcode = $ _POST ['iced']; $ Itemname = $ _POST ['Innam']; $ Brand name = $ _POST ['brand name']; $ Upload = basename ($ _FILES ['upload'] ['name']); $ Path = "IMG /"; If (! $ Uploaded)! {$ I1 = strrpos ($ Upload, "."); If (! $ I1) {return ""; } $ L1 = Stellen ($ Upload) - $ i1; $ Ext1 = substr ($ Upload, $ i1 + 1, $ l1); $ Ext1 = Strontoloyer ($ ext1); $ News_name1 = time () + (1) $ ext1 '.' $ Newname1 = $ path $ News_name1; $ Copied1 = copy ($ _ files ['upload'] ['tmp_name'], $ newname1); } And {$ news_name1 = ''; } $ Iadd = $ mysqli-> Prepare ("table_itim (` itemcode`, `item name`,` brand name`, `upload`) values (". $ Itemcode. "'', '". $ Itemname.' ',' ". $ Brandname . '' ',' ". $ News_name1." ') "); $ IAD-> Executed (); $ IAD-> near (); $ Mysqli- & gt; near (); Var_dump ($ _ files); }? & Gt;
Your var_dump says "file is already managed" Additionally, you say The database recording that works (which is your last statement), so whatever problem is, it does not use errors for php. So you do not have any errors or there is no error for php.
- Run your program and check
C: \ xampp \ tmp \
if any file is created & amp; Destroyed. - Verify that you are viewing the correct
img /
directory.
As used by Rocket-Hazrat, use move_uploaded_file () instead of
copy
.
Comments
Post a Comment