Posted by gavri on September 14, 2007 at 7:48am
hi,
im trying to populate a node using node.save service.
Does anyone manged to populate a cck image field through flash.
i know how to upload a file directly to the server as seen in: http://www.flash-db.com/Tutorials/upload/index.php, but I'd really like to use the functionality of the upload module.
any suggestions?
thaks,
gavri

Comments
tmp directory is the key
I found your post while searching for an answer, then went about figuring out one myself!
What works for me is to upload the file via flex fileReference class to a directory in the Drupal root, for example flex/images... when the upload is complete I save the node with the following data structure:
private function drupal_save () {
var images_array = new Array();
images_array["_original"] = relative_URL;
var properties:Object = {type: "image",
nid: nid, title: title_value,
images: images_array,
body: body_value
};
if (parentDocument) parentDocument.save_node (properties);
}
Register this same directory as the temporary files directory, and Drupal should take care of the rest...
it's a beginning!
thanks :)
thanks :)
are you sure this work?
i tried on a vanilla install of drupal, minimum setup:
cck
imagefield
services
amfphp
i try to create a simple node and it works perfectly: eg:
public function saveNode():void{var nodeObject:Object = new Object();
nodeObject.type = "page";
nodeObject.nid = 0; // set to zero to create new node
nodeObject.title = title.text;
nodeObject.created = "2009-1-14";
node.save(nodeObject);
}
so far works perfectly.
now i try to add your tecnique:
public function saveNode():void{var nodeObject:Object = new Object();
var images_array:Array = new Array();
images_array["_original"] = "base_media.jpg";
nodeObject.type = "page";
nodeObject.nid = 0; // set to zero to create new node
nodeObject.title = title.text;
nodeObject.field_image = images_array;
nodeObject.created = "2009-1-14";
node.save(nodeObject);
}
i want to try with a static file first to make sure to isolate the problems.
in order to avoid path problem, i just copied the file "base_media.jpg" everywhere.
anyway, the node is created, but the file is completely ignored.
i am getting creazy, how can i register a file in drupal useing services? :S
code
Anybody has some code example, i need to upload a document, are you guys using the regulare file upload component and then passing back the filename/path from drupal to flash?
i made the following, can
i made the following, can you guys have a look and give me some feedback http://groups.drupal.org/node/13781
Cheers
Peter