Missing Images

Carsten Haese carsten.haese at gmail.com
Sat Dec 26 11:28:44 EST 2009


Victor Subervi wrote:
> For some reason, I'm not able to upload images to insert into my
> database. Here's my html:
> 
>     <td>Picture #1</td>
>     <td>
> <input type="file" name="pic0" />
>     </td>
>   </tr><tr>
>     <td>Picture #2</td>
>     <td>
> <input type="file" name="pic1" />
>     </td>
> 
> Here's the code from the page that processes the data from the preceding
> form:
> 
>   i = 0
>   for picsStore, num in pics().iteritems():
>     if picsStore == store:
>       numPics = int(num)
>   while i < numPics:
>     y += 1
>     pic = form.getfirst('pic%d' % i)
>     try:
>       if len(pic) > 0:
>         ourPics.append(pic)
>  
> The output, however, when I print out ourPics, is just the names of the
> images (e.g., "image.jpg"). I haven't included complete code because it
> appears to me that my code is working perfectly well, but I've simply
> not coded to achieve my goal which, obviously, is to capture the image
> itself, not its name. What have I missed?

It's hard to say what you have missed, since you're not giving us nearly
enough information to determine what you haven't missed. So, we can now
either beg for more information, make random guesses, or point you at a
 code example that shows how file uploads are done with the cgi module.
I'll do the latter:

http://webpython.codepoint.net/cgi_file_upload

--
Carsten Haese
http://informixdb.sourceforge.net




More information about the Python-list mailing list