diff --git a/client/Gallery3.php b/client/Gallery3.php
index d1135ae9..83ed7b2d 100644
--- a/client/Gallery3.php
+++ b/client/Gallery3.php
@@ -129,10 +129,16 @@ class Gallery3 {
* @return object Gallery3
*/
public function save() {
- $response = Gallery3_Helper::request(
- "put", $this->url, $this->token,
- array("entity" => array_diff((array)$this->data->entity, $this->original_entity),
- "members" => $this->data->members));
+ $data = array();
+ $data["entity"] = array_diff((array)$this->data->entity, $this->original_entity);
+ if (isset($this->data->members)) {
+ $data["members"] = $this->data->members;
+ }
+ if ($this->file) {
+ $response = Gallery3_Helper::request("put", $this->url, $this->token, $data, $this->file);
+ } else {
+ $response = Gallery3_Helper::request("put", $this->url, $this->token, $data);
+ }
return $this->load();
}
diff --git a/client/example.php b/client/example.php
index 1c96cd1b..5bfc49a2 100644
--- a/client/example.php
+++ b/client/example.php
@@ -39,13 +39,19 @@ for ($i = 0; $i < 2; $i++) {
->set("type", "photo")
->set("name", "Sample Photo.png")
->set("title", "Sample Photo")
- ->set_file("gallery.png")
+ ->set_file("test1.png")
->create($album->url, $auth);
alert("Uploaded photo: {$photo->url}");
}
$album->load();
alert("Album members: " . join(", ", $album->data->members) . "");
+
+alert("Replace the data file");
+$photo->set_file("test2.png")
+ ->save();
+
+
$comment = Gallery3::factory()
->set("item", $album->data->members[0])
->set("type", "comment")
@@ -93,7 +99,6 @@ $tag_relationship2->delete();
$tag->load();
alert("1 remaining tag: {$tag->data->relationships->items->members[0]}");
-
alert("Delete the album and tag");
$album->delete();
$tag->delete();
diff --git a/client/gallery.png b/client/test1.png
similarity index 100%
rename from client/gallery.png
rename to client/test1.png
diff --git a/client/test2.png b/client/test2.png
new file mode 100644
index 00000000..fdc97779
Binary files /dev/null and b/client/test2.png differ