Witam mam aplikację, która robi zdjęcie telefonem z Androidem i następnie wysyła to zdjęcie na serwer FTP za pomocą kodu php ze strony.
Kod wygląda tak
  1. <?php
  2.  
  3. // Path to move uploaded files
  4. $target_path = "uploads/";
  5.  
  6. // array for final json respone
  7. $response = array();
  8.  
  9. // getting server ip address
  10. $server_ip = gethostbyname(gethostname());
  11.  
  12. // final file url that is being uploaded
  13.  
  14. $file_upload_url = 'http://brzanek.webd.pl/AndroidFileUpload/uploads/';
  15.  
  16.  
  17. if (isset($_FILES['image']['name'])) {
  18. $target_path = $target_path . basename($_FILES['image']['name']);
  19.  
  20. $email = isset($_POST['email']) ? $_POST['email'] : '';
  21. $website = isset($_POST['website']) ? $_POST['website'] : '';
  22.  
  23. $response['file_name'] = basename($_FILES['image']['name']);
  24. $response['email'] = $email;
  25. $response['website'] = $website;
  26.  
  27.  
  28. try {
  29. // Throws exception incase file is not being moved
  30. if (!move_uploaded_file($_FILES['image']['tmp_name'], $target_path)) {
  31. // make error flag true
  32. $response['error'] = true;
  33. $response['message'] = 'Could not move the file!';
  34. }
  35.  
  36. // File successfully uploaded
  37. $response['message'] = 'File uploaded successfully!';
  38. $response['error'] = false;
  39. $response['file_path'] = $file_upload_url . basename($_FILES['image']['name']);
  40. }
  41.  
  42.  
  43.  
  44.  
  45. //$con = new mysqli("localhost","brzanek_brzanek","dj4403dj","brzanek_android");
  46. //$date = date('hisdmY');
  47. //$date = date('Y-m-d');
  48. //$image = $_POST['image'];
  49.  
  50.  
  51.  
  52. catch (Exception $e) {
  53. // Exception occurred. Make error flag true
  54. $response['error'] = true;
  55. $response['message'] = $e->getMessage();
  56. }
  57. } else {
  58. // File parameter is missing
  59. $response['error'] = true;
  60. $response['message'] = 'Not received any file!F';
  61. }
  62.  
  63. // Echo final json response to client
  64. echo json_encode($response);
  65. ?>


Chciałbym dołączyć do tego możliwość zapisywania nazwy zdjęcia w bazie danych. Mam już przygotowaną bazę danych z trzema kolumnami.
- id
- data
- image
Jak dopisać to w tym pliku php aby to zadziałało. Próbowałem standardowo jak to się robi za pomocą formularza ale nie wychodziło. Proszę o pomoc z góry dziękuję.