Monday, November 08, 2010 at 12:00 AM.

scripting2Suite.editor.uploadImageFile

on uploadImageFile (f) {
	<<Changes
		<<7/1/10; 6:26:47 AM by DW
			<<Created. 
	local (adrdata = scripting2suite.init ());
	local (username = adrdata^.editor.prefs.username);
	local (password = string (adrdata^.editor.prefs.password));
	local (server = string (adrdata^.editor.prefs.server));
	local (fname = file.filefrompath (f), ext = string.lower (string.lastfield (fname, ".")));
	if (ext == "gif") or (ext == "jpg") or (ext == "jpeg") {
		local (bits = file.readwholefile (f), type = user.webserver.prefs.ext2MIME.[ext]);
		local (atts = [server].scripting2.saveImage (username, password, fname, type, bits));
		adrdata^.editor.prefs.watchedFolder.ctUploads++;
		adrdata^.editor.prefs.watchedFolder.whenLastUpload = clock.now ();
		adrdata^.editor.prefs.watchedFolder.urlLastUpload = atts.url;
		return (atts.url)}};
bundle { //test code
	url = uploadImageFile ("ohio:pictures:cmsdiagram.jpg");
	webbrowser.openurl (url)}



This listing is for code that runs in the OPML Editor environment. I created these listings because I wanted the search engines to index it, so that when I want to look up something in my codebase I don't have to use the much slower search functionality in my object database. Dave Winer.