[Zope-DB] Help on uploading images to Postgresql
CY
CY" <cyhoong@pc.jaring.my
Sat, 5 Apr 2003 11:05:58 +0800
This is a re-send. My previous email was badly cluttered up.
Hello Zopist
I need some help in uploading .gif & jpeg files to Postgresql.
My current server is running Zope2.5.1 on RH8.0 with Postgresql7.2.2.
I have create a simple form to capture some digital images for uploading to
Zope server from my PC (WIn98).
However I encounter an error message (below).
The system is looking for the images in Zope server while the actual image
for uploading resides in the PC. How I do "tell" the Zope the location of
the image file?
TQ in advance
Error message:
==========
Z SQL Method at /STARS/Photo/uploadPhoto_sql Help!
--------------------------------------------------------------------------
Error, psycopg.IntegrityError: ERROR: lo_import: can't open unix file
"g:imagesirds.gif": No such file or directory insert into photo( person_id,
comments, pic) values ('robert', 'happy bird day', lo_import
('g:\images\birds.gif') )
----------------------------------------------------------------------------
SQL used:
insert into photo(
person_id, comments, pic)
values
('robert',
'happy bird day',
lo_import ('g:\images\birds.gif')
)
Photo upload Form
==============
<dtml-var standard_html_header><h2><dtml-var title_or_id></h2>
<form action="uploadPhoto_action" method="post"><table>
<tr> <td>Person ID:</td>
<td><input type="text" name="person_id" maxlength="16"
size="20"></td>
</tr>
<tr> <td>Comments:</td>
<td><input type="text" name="comments" maxlength="20"
size="20"></td>
</tr>
<tr> <td>Filename: </td>
<td><input type="file" name="pic" accept="image/*">
</tr>
<tr><td> </td></tr>
<tr> <td align="right"><input type="reset" name="submit"
value="Reset"></td>
<td><input type="submit" name="submit" value="Upload"></td>
</tr>
<dtml-var standard_html_footer>
uploadPhoto_action Method
====================
<dtml-var standard_html_header><h2><dtml-var title_or_id> <dtml-var
document_title></h2>
<dtml-call "uploadPhoto_sql (cust_id=REQUEST.get('person_id'),
comments=REQUEST.get('comments'),
pic=REQUEST.get('pic') )">
<dtml-call "RESPONSE.redirect('uploadPhoto_form')">
<dtml-var standard_html_footer>