Search code examples
phprackspace-cloudrackspace

Incorrect content type using rackspace form post


I am using form post method to post some files to one of my containers on rackspace. Problem is if i upload a pdf first and then a png in 1 go, It is trying to open png in pdf viewer. Upon checking I came to know that the "Content-type" was set to "application/pdf" for png.

My form is something like

<form id="form" accept-charset="utf-8" action="action" method="POST" enctype="multipart/form-data" novalidate="novalidate">
<input type="hidden" name="redirect" value="rediredt url">
<input type="hidden" value="" name="max_file_size">
<input type="hidden" value="" name="max_file_count">
<input type="hidden" value="" name="expires" id="rack_expire">
<input type="hidden" value="" name="signature" id="rack_signature">

<div class="contentRow fileUploadWrap">
<p><input id="file2" type="file" name="file_1"></p>
<p><input id="file2" type="file" name="file_2"></p>
<p><input id="file3" type="file" name="file_3"></p>
<p><input id="file4" type="file" name="file_4"></p>
<p><input id="file5" type="file" name="file_5"></p>
<div class="contentRow">
<div class="submit"><input id="uploadFilesBtn" class="btn btn--primary" type="submit" value="Upload"></div> </div>
</div>

</form>

I cant find a way to set the content type for the files being uploaded. Is there any way i can fix this.


Solution

  • Only workaround i found for this is to update the content type of the uploaded files using api methods mentioned here.

    I was already saving the file names so i just did a post CURL to update the info and that fixed the issue.