how to upload any file into MySQL using PHP. I am using ionic (angular )?. Looking for simple solution with a PHP backend. Thanks in Advance. Please share references here.
This probably is the right place to ask about PHP since this forum is for Ionic related questions Luckily I am an Ionic and PHP developer. Are you using a PHP framework? If not, I would highly recommend Laravel. It is awesome to work with and has a fantastic community.
To upload a file, you would do a
POST with your Ionic app to an API endpoint in PHP/Laravel. Here is how to handle file uploads in Laravel.
To store it in MySQL, I would convert the file bytes to Base64.
Hopefully that gives you a good start.
Ok. thanks for your response. I want to upload a file to MySQL database using PHP through an ionic framework(Angular). I am new to ionic.
Right, I understand that. Uploading a file with Ionic is just like any other file upload in a web app. Within Ionic, you’ll need to make a web request to your backend API endpoint in PHP. I haven’t worked with file uploads yet in Ionic, but most likely you will need a Capacitor/Cordova plugin in order to allow the user to choose a file from the file system to upload.
What benefit do you see from doing that that would outweigh the extra 30+% storage required?
That is my bad. In MySQL I would probably use a
BLOB. I was thinking of a past project that for some reason we converted files to Base64 in MS SQL instead of using
varbinary. Ultimately, I would try to not store any files in a database.