cURL / Mailing Lists / curl-and-php / Single Mail

curl-and-php

Re: Set content-type for http post upload file not possible

From: Morgan Galpin <morgan_at_atsourceinc.ca>
Date: Wed, 12 Dec 2007 15:50:34 -0800

It seems to me that curl is about automating tasks. A common task is
uploading a file along with that file's content type. Would it not be
easier for curl users if curl was able to automatically determine the
content type of files rather than requiring users to determine the
content type themselves and manually set it? There is already a function
in libcurl that returns the content type for a given file name. It is
logical to me that this function should be able to return the content
type for more than 5 hard-coded types. Being able to override this
determination is an excellent feature, but I feel the automatic type
detection could be more flexible. I think it is helpful to be able to
accomplish the same task in more than one way. However, I'm sure the
developers are all very busy working on higher priority features, which
is fine by me.

I agree that PHP's support for curl could be done better. Not the least
of which is better documentation for the many options, much like the way
curl documents the same options. I'm sure they will continue to improve
it. It is on my todo list to submit a feature request to support setting
the content type.

Daniel Stenberg wrote:
> On Wed, 12 Dec 2007, Morgan Galpin wrote:
>
>
>> If the end of the filename matches one of the extensions, then it will
>> insert the associated mime type for the "Content-type:". If it isn't one of
>> the 5, then the mime type is "application/octet-stream". These 6 types are
>> hard-coded into cURL. There is no way to change the set of mime types
>> without modifying the source code and recompiling it. :-( It should read
>> some kind of mime.magic file instead.
>>
>
> No it shouldn't. It provides a way for the application to set whatever type it
> pleases, and that's the way apps should set a preferred type.
>
>
>> If either the PHP-curl interface or cURL code were changed to accommodate
>> this kind of upload, I could get my application to work.
>>
>
> libcurl offers this feature and as you say the command line tool works fine
> and can change it.
>
> PHP/CURL's formpost support is weird and someone should fix that properly and
> while doing that they could also make sure that changing the content-type gets
> supported. Just cramming in content-type support without fixing the whole mess
> will only make it even messier.
>
>
_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2007-12-13