I want to be able to upload an image to the server, but instead of saving the image as a byte in the database To save the path, so that I call the image through its path in the watch page. Also when the uploaded image should be uploaded in a fixed folder, if the folder is not found, then one. All it should use MVC5, any help is actually appreciated
is not sure That's the language you want to do in this language, but it's the implementation method you want to save to the database.
- Save the folderpath + 'filename' to the database
Here is a PHP method upload (), to handle steps 3 and 4 of the server API Share
// Upload API function upload ($ ID, $ PhotoData, $ title) found on {// index.php this function $ $ _SESSION [' IdUser '] //'s first parameter Nearby as $ _SESSION [ 'IdUser'] should be in the user ID, if the user is already authorized / remember /? If you store the User ID in the login function (! $ Id) errorJson ('Authority required'); // Check that there was no error during file uploads ($ photoData ['error'] == 0) {// Insert details about the photo in the "Photo" table $ result = query ("(included in the photo IdUser, title) VALUES ('% d', '% s') ", $ id, $ title;); If ($! ['Error']) {// Receive active connection in database (this is automatically started in lib.php) Global $ link; // Get the last Auto-generated ID in the Photo Table $ IdPhoto = mysqli_insert_id ($ link); // Move a temporary stored file to a convenient location // Your photo is automatically saved by PHP in a template folder / you need to move it to your own "upload" folder (move_uploaded_file ( $ PhotoData ['tmp_name'], "upload / .adifota." .jpg ")) {// file moved, generate all the best thumbnails thumb (" upload / / .avi id ".jpg ", 180); // Now print the iPhone app print json_encode (array ('successful' => 1)); } Else {// Print an iPhone app error Json ('upload on server problem') to an error message; }; } Else {errorJson ('upload database problem.' $ Result ['error']); }} And {errorJson ('upload malfunction'); }}
Comments
Post a Comment