I’m writing a plugin for wordpress where certain information like a name and e-mailaddress and some info is stored in an SQL database table. I’ve got that working perfectly. But this information also needs a picture to go with it.
So when wordpress admin fills in the form, has the file selected and clicks submit I want the file to be uploaded into a directory and its location stored in a database along with the name and e-mailaddress.
All this preferably needs to be done in just one form.
Is this possible? Or is there another way that would make the end user click only once on a sumbit button.
Yes, it’s possible. Just make sure you set the form
enctype="multipart/form-data"and that you usetype="file"for file input and regular inputs (type="text", etc) for texts.You’ll need to write a code to move uploaded files to a location you want, as well as to add its info to the database.
See these two nice tutorials: here and here.