]> dev.renevier.net Git - syp.git/blobdiff - api.php
images stored on ftp server
[syp.git] / api.php
diff --git a/api.php b/api.php
index 052b5145a47e5aef5701b72648896a3c08367369..302c1c75461376ad8c56889e9e84ed85327be913 100644 (file)
--- a/api.php
+++ b/api.php
@@ -98,19 +98,13 @@ function save_uploaded_file ($file, $con) {
                 (!move_uploaded_file ($file ["tmp_name"], $dest))) {
             server_error ();
         }
+        send_to_ftp ($dest);
         $mini_dest = getthumbsdir () . "/mini_" . basename_safe ($dest);
 
-        try {
-            $thumbnail_ok = create_thumbnail ($dest, $mini_dest);
-        } catch (Exception $e) {
-            $thumbnail_ok = false;
-        }
-        if (!$thumbnail_ok) {
-            if (!copy ($dest, $mini_dest)) {
-                server_error ();
-            }
+        if (!create_thumbnail_or_copy ($dest, $mini_dest)) {
+            server_error ();
         }
-
+        send_to_ftp ($mini_dest);
     }
     return basename_safe ($dest);
 }
@@ -139,11 +133,13 @@ function delete_image_if_unused ($imgpath, $con) {
     $path = UPLOADDIR . "/" . $imgpath;
     if (file_exists ($path)) {
         unlink ($path);
+        delete_from_ftp ($path);
     }
 
     $thumb_path = getthumbsdir () . "/mini_" . $imgpath;
     if (file_exists ($thumb_path)) {
         unlink ($thumb_path);
+        delete_from_ftp ($thumb_path);
     }
 }