[EMAIL PROTECTED] wrote:
I would like to know how to add image file from an URL. I created a
form with to pissibilities: add an image from a local file , and a
image from an url

You can get an image from a url with an External Method:

# Get an image using the original url.
import urllib
def getImage(url):
    f = urllib.urlopen(url)
    data = f.read()
    f.close()
    return data

Hope this is enough to put you on track.

Cliff

here is my form: <input type="radio" name="sourcePicture" checked
onClick="lock_option()" value="file"> get from disk: <input
type="file" name="pict_file" size="40" accept="image"
maxlength=500000>

<br>

<input type="radio" name="sourcePicture" onClick="lock_option()"
value="internet"> get from the internet<input type=text
name="pict_internet" size="40"
value="http://www.monsite.fr/monimage.jpg"; disabled="disabled">

This form call a python script:

if REQUEST.sourcePict=="file": pathImgs.manage_addProduct['OFSP'].manage_addImage("pict_"+id,
REQUEST.pict_file, title="pictogramme metier", precondition="",
content_type="") else: pathImgs.manage_addProduct['OFSP'].manage_addImage("pict_"+id,
REQUEST.pict_internet, title="pictogramme metier", precondition="",
content_type="")



With a locl file it works (case sourcePict=file), but when I want to add images from an url, it doesn't work. I suppose that the second parameter of manage_addImage must be a file type.In the first case, it works , but in the second, the parameter passed is a string (complete url of the image). so how to do?

thanks for your answers and excuse me for the lack in English (I'm
french) _______________________________________________ Zope maillist
- Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No
cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )



_______________________________________________
Zope maillist - Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
** No cross posts or HTML encoding! **
(Related lists - http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope-dev )

Reply via email to