Trouble uploading images to AWS s3 and XAMPP

So I needed to get my local xampp development site working with AWS s3 to store images.  I had it set up and working on my development server but I needed my local development to work as well. Unfortunately I kept getting this error.

Aws\S3\Exception\S3Exception with message ‘Error executing “ListObjects” on “https://mybucket.s3-ap-southeast-2.amazonaws.com/?prefix=&delimiter=%2F&encoding-type=url”; AWS HTTP error: cURL error 60: SSL certificate problem: unable to get local issuer certificate (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)’

I Googled for a solution and everywhere I found that I needed to change my php.ini file to include a certificate. Unfortunately everywhere told me to get a clean cacert.pem and do the following in the php.ini file.

curl.cainfo=C:\path\to\cert\cacert.pem

This did not work for me.  More searching and a bit of trial and error lead me to this.

openssl.cafile=C:\path\to\cert\cacert.pem

And badda-bing badda-boom it works!

Hope this helps someone save some hours.

Uploading a file with ajax serialize() does not work?

This was driving me nuts as I often use Ajax to save different data without refreshing the page, however when I tried to use it for a multipart form when uploading an image, it would not work.

After a bit of searching I found this solution which worked for me.

The form:

<form class="form-inline" id="imageUpload" enctype="multipart/form-data">
    <div class="form-group" >
        <label for="file">Select image to upload:</label>
        <input type="file" name="file" id="file" >
     </div>
     <button type="submit" class="btn btn-primary">Upload Image</button>
</form>

The ajax:

<script type="text/javascript">
    $(document).ready(function() {
        $("#imageUpload").submit(function(e) {
            e.preventDefault();

            var formData = new FormData(this);

            $.ajax({
                type: "POST",
                data: formData,
                cache:false,
                contentType: false,
                processData: false,
                url: "/activity/add/photo",
                dataType: "json",
                success: function(data) {
                    $('#imagedisplay').html(data.name);
                },
                error: function() {
                    $('#imageerror').html('data.file');         
                }
            });
        });
    });
</script>