Darren Dignam Member |
# Posted: 14 Sep 2009 23:29
Hi,
I have just started using wyzz. I like it a lot, its lightweight, and you can tweak it to how you like! I have been trying for a few days to use imageshack API for image uploading, and now I have it working, and working in wyzz too, I thought I would share my findings here with the community!
The principle behind my technique is based on iFrame AJAX (for that seamless user experience ;), and I have explained in detail on my blog the imageshack side of things:
http=//www_blocsoft_com/blog/imageshack_asp
For my approach, you need a form, and a hidden iFrame (called AXframe, style="visibility:hidden"). I create the form in JS in my modified insertImage function:
[ I cant put URL's in my first post... or my code it seems..... I am about to give up, but i think this is useful for other wyzz users... so I will copy this post to my blog, if you want, go and check it out: www_blocsoft_com/blog/wyzz.asp ;]
function insertImage(n) {
[......... see blog for full code ........]
}
It looks nasty I know - sorry - this is still WIP! I had to use a global var global_n to remember which wyzz we are dealing with (I have only 1 wyzz editor on screen at any given time anyway, so i dont see a problem with this, if anyone can suggest a better way, im all ears!)
The form will hide itself when you submit the image, and the hidden iFrame performs the upload, on completion either an image URL is inserted into the wyzz window, or an error alert is generated. read my blog above for the details of how this works ;)
The imageshack API redirects to a page of your choosing on successful upload, and this page has javascript in it, that using global_n inserts the image, this is the code in my sucess.asp file (this could be done with PHP just as easily ;)
success.asp
<%
str1 = Request("1")
str2 = Request("2")
str3 = Request("3")
str4 = Request("4")
str5 = Request("5")
%>
[......... see blog for full code ........]
FF and IE do things differently, hence the check. This code is a stripped down verison of what I am working on, so please feel free to post any errors I may have made. I have got this work!! And in due course I will link to an example. Please make any suggestions too!!!
The error page is a simple alert('image upload failed, please try again');
Darren
|