sql - How to insert an Attachment into an Access database using PHP? -


i need add files uploaded html form ms access ddbb. using php, sql , odbc haven't had problem queryng access file, except attachment fields.

insert temas (datosadjuntos.filename, datosadjuntos.filedata) values ("examplename.txt", "wathever") id = 4; 

this query returns following error:

sqlstate[07009]: invalid descriptor index: -1003 [microsoft][controlador odbc microsoft access] argumento no vĂ¡lido. (sqlexecute[-1003] @ ext\pdo_odbc\odbc_stmt.c:260) 

no matter put instead of "wathever", error same. except if empty string, query runs no problem, , works, can see in next image.

any idea of should put in query make work, or other way of inserting attachment ms access ddbb?

thanks

erik right: can't insert attachment using odbc. need use access dao, so:

$dbe = new com("dao.dbengine.120") or die("cannot create dbengine object."); $db = $dbe->opendatabase("c:\\users\\public\\database1.accdb"); $rsmain = $db->openrecordset("select datosadjuntos temas id=4", 2);  // dbopendynaset $rsmain->edit; $rsattach = $rsmain->fields("datosadjuntos")->value; $rsattach->addnew; $fldattach = $rsattach->fields("filedata"); $fldattach->loadfromfile("c:\\users\\gord\\desktop\\sample.pdf"); $rsattach->update; $rsattach->close; $rsmain->update; $rsmain->close; $db->close; 

note access dao component of access database engine, approach not require full install of microsoft access application.


Comments

Popular posts from this blog

What is happening when Matlab is starting a "parallel pool"? -

angular - DownloadURL return null in below code -

php - Cannot override Laravel Spark authentication with own implementation -