mirror of
https://github.com/HaschekSolutions/pictshare.git
synced 2026-04-25 06:55:56 +03:00
[GH-ISSUE #105] Can't access to json Obj when uploading an image #80
Labels
No labels
Feature request
Feature request
bug
cant reproduce
enhancement
help wanted
pull-request
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/pictshare#80
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @vitalijalbu on GitHub (Jan 21, 2020).
Original GitHub issue: https://github.com/HaschekSolutions/pictshare/issues/105
When i try to upload an image i would like to get only hash ID and save it into DB.
But response object can't be accessible.
@geek-at commented on GitHub (Jan 21, 2020):
what do you mean you can't access the json object? When you upload an image
eg via curl:
curl -s -F "file=@/path/to/your/image.jpg" https://pictshare.net/api/upload.phpyou get the answer in form of a JSON object that defines the hash and path.@vitalijalbu commented on GitHub (Jan 21, 2020):
yes right, i get that json response but i can't access to hash and then save into DB.
for example i have this global function that helps me to upload an image:
public function upload_img($file) {
Now i'd like to get only hash ID from $output, but is returns NULL
@geek-at commented on GitHub (Jan 21, 2020):
To get the response using the curl php extension you need to set returntransfer to true.
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);Also, because the answer from the server is a JSON object you'll have to parse it first before being able to use it as an array
Try this
@vitalijalbu commented on GitHub (Jan 21, 2020):
thanks it's working :D