CGI, stdin, image handling

Richard Miller wow at together.net
Wed Jan 23 17:19:06 EST 2008


Mark,

Am I sure? Definitely not!

However, I don't think there's much parsing to do. I've set up a  
simple html test page with nothing on it but a file upload box and  
button... a standard multipart/form-data with POST as the method. As  
I said, when the data stream comes in, I'm using the standard "read  
from stdin until empty" routine in the repeat loop. I then put the  
data into a file. What I'm not sure about is: 1) do I urldecode the  
data before sticking it in the file? and 2) do I use...  put (the  
data) into url "file:x.jpg" or put (the data) into url "binfile:x.jpg?

In any event, I've tried all the variations of this. I still get  
several lines of data at the beginning of the file (which contains a  
long number, following by "Content-Disposition: form-data;  
name="upfile" etc.. etc..) which shouldn't be part of the file, plus  
this same long number at the end of the data file. I've managed to  
take both of those sections out. But when I compare this file to the  
original, I notice there are still a small (but obviously  
significant) number of extra characters interspersed in the data that  
shouldn't be there. I see no way to get those out.

Bottom line: somethings not correct.. or perhaps this approach just  
won't work.

Richard


On Jan 23, 2008, at 5:05 PM, Mark Smith wrote:

> Richard, please disregard the base64 thing - not sure what I was  
> thinking!
>
> I'm wondering how these PHP scripts get the jpegs ok, but the rev  
> cgi doesn't. Are you sure that your cgi is parsing the posted data  
> correctly?
>
> Best,
>
> Mark
>
> On 23 Jan 2008, at 21:28, Richard Miller wrote:
>
>> Mark,
>>
>> I'm not quite sure what you're suggesting. I have no control of  
>> the files before they are uploaded through a browser. These files  
>> could come from any user.  Are you suggesting to take the data  
>> that comes in through the Rev CGI and use base64decode on it  
>> before saving it?
>>
>> The other route I've been pursuing is to use a PHP-based file  
>> upload script to bring the files into the server. There are dozens  
>> of those scripts and they all work fine. The problem I have is  
>> that these scripts simply upload a file to a given directory and  
>> store it, but provide no means to identify the source of the file.  
>> In my case, for each JPEG that comes in, those images are  
>> associated with specific records in my database. I haven't figured  
>> out how to identify which record any given JPEG is associated  
>> with. Seems that none of these PHP scripts provide for a way to  
>> capture additional information on the uploaded images. They just  
>> store file under its original file name. This process would be  
>> much easier if I could get the Rev CGI to pull in the image files.
>>
>> Thanks.
>> Richard
>>
>>
>> On Jan 23, 2008, at 4:10 PM, Mark Smith wrote:
>>
>>> Richard, have you tried base64encoding the data before posting?
>>>
>>> best,
>>>
>>> Mark
>>>
>>> On 23 Jan 2008, at 20:59, Richard Miller wrote:
>>>
>>>> I'm trying to use the CGI POST method and stdin to grab a JPEG  
>>>> file through a browser. The file comes in and I can save it (as  
>>>> a binary file), but the file data is a bit corrupted...  
>>>> particularly at the beginning and end. I can delete those  
>>>> sections, but I'm still noticing some extra characters  
>>>> throughout the file. I don't know why this is and if it can be  
>>>> fixed, but without that, the routine simply doesn't work. Is  
>>>> there any hope for this method of capturing image files from a  
>>>> user via a browser?
>>>>
>>>> Thanks.
>>>> Richard Miller
>>>> _______________________________________________
>>>> use-revolution mailing list
>>>> use-revolution at lists.runrev.com
>>>> Please visit this url to subscribe, unsubscribe and manage your  
>>>> subscription preferences:
>>>> http://lists.runrev.com/mailman/listinfo/use-revolution
>>>
>>> _______________________________________________
>>> use-revolution mailing list
>>> use-revolution at lists.runrev.com
>>> Please visit this url to subscribe, unsubscribe and manage your  
>>> subscription preferences:
>>> http://lists.runrev.com/mailman/listinfo/use-revolution
>>
>> _______________________________________________
>> use-revolution mailing list
>> use-revolution at lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your  
>> subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-revolution
>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your  
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution




More information about the use-livecode mailing list