I'm trying to create an image in my server's uploads directory from base64 code sent from the client-side. Below's the code for same :

```
<?php
    $dataURI = $_REQUEST['dataURI'];

    $dataURI = str_replace('data:image/png;base64,', '', $dataURI);
    $dataURI = str_replace(' ', '+', $dataURI);

    $data = base64_decode($dataURI);

    // $filename = UPLOAD_DIR . uniqid() . '.png';
    $filename = UPLOAD_DIR . 'saved-image' . '.png';

    $status = file_put_contents($filename, $data);

?>

```

the image is successfully created, but for some reason the image is cropped to half(horizontally). Could anyone tell me , what's wrong with this ? 

Below is the original and saved/created image : 

Original Image

![](https://farm8.staticflickr.com/7283/8741490620_5aaaf057e5.jpg) 

Created Image

![](https://farm8.staticflickr.com/7282/8741491818_0c034ecfbc.jpg)