# How to get uploaded image url using the Discourse API?

**URL:** https://meta.discourse.org/t/how-to-get-uploaded-image-url-using-the-discourse-api/37800
**Category:** Development
**Tags:** rest-api
**Created:** [12.Январь.2016 03:51:27 UTC](https://meta.discourse.org/t/how-to-get-uploaded-image-url-using-the-discourse-api/37800 "2016-01-12T03:51:27Z")
**Posts on this page:** 1
**Showing post:** 6

<div class="post-metadata">

### Author: ![sleep](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sleep/32/48342_2.png) [@sleep](https://meta.discourse.org/u/sleep)
#### Post date: [13.Январь.2016 07:54:51 UTC](https://meta.discourse.org/t/how-to-get-uploaded-image-url-using-the-discourse-api/37800/6 "2016-01-13T07:54:51Z")

</div>

Thank you.😛

> [@Discourse REST API Documentation](https://meta.discourse.org/t/discourse-rest-api-documentation/22706/1):
>
> Upload Image from File
> 
> POST /uploads
> 
> Parameters
> 
> username  
> type  
> file  
> synchronous
> 
> Example

```shell
curl -X POST -F username="john" -F type="image" -F file="@image.png" -F synchronous="true" "http://localhost:3000/uploads?api_key=SOMETHING&api_username=SOMEONE"

```

I write a php fucntion to test this upload api.

```php
public function upload_file($user) {
  $url = 'http://hostname/uploads?api_key=api_key&api_username=api_username';
  $poststr = http_build_query(array('username' => $user, 'type' => 'image', 'file' => '/uploads/file/filename', 'synchronous' => 'true');
  $data = _curl($url, $poststr)); // _curl() : a custom function 
  return $data;
}

```

$data is empty. Why is it empty? It’s not supposed to return a url.

if I remove a parammeter : synchronous, it will return the response of “{“success”:“OK”}”.

---

_[View the full topic](https://meta.discourse.org/t/how-to-get-uploaded-image-url-using-the-discourse-api/37800)._
