Have tried the API call as listed on Podio dev site to upload a file and I am not getting much joy.
I am trying to "Upload a file" in the first instance using the POST operation and passing the json with the source url to the endpoint as specified.
I can use other methods just fine but since there is little in the way or error feedback I am stuck I keep getting error 404
I have used - https://developers.podio.com/doc/files/upload-file-1004361
(have tried both GET & POST)
image of method with error i get
Upload file method that you are trying to use (https://developers.podio.com/doc/files/upload-file-1004361) is expecting file path which is supposed to be local file but not url.
Here is example of how it should be used:
http://podio.github.io/podio-php/api-requests/
$file = PodioFile::upload($path_to_file, $filename_to_display);
print 'File uploaded. The file id is: '.$file->id;
Here is another example on how to work with files:
https://developers.podio.com/examples/files
Related
Do the following steps to Understand the problem clearly :
Open notepad.
Type something and save it as " .png " (or any other image format).
Try to upload it as a image file with extension validation.
Now try to display it.
Expected : To show error while uploading
Actual : The file gets easily uploaded without any problem and error occurs only while accessing it.
mime_content_type() is deprecated function.
instead you can use
<?php
print_r(getimagesize("listing.png"));
?>
if this shows error then the file is invalid png file. If file is valid it returns an array of information.
Edit: This works if you are working with images only.
I've got a script, largely based on an example uploading PHP file from jQuery Uploader. It gets file type with the following code (it gets this $_FILES component)...
$fileType = (isset($_SERVER['HTTP_X_FILE_TYPE']) ? $_SERVER['HTTP_X_FILE_TYPE'] : $upload['type']);
Note; $upload['type'] comes from the $_FILES['files']['type'].
Now, this is fine - except for the fact that some files seem to have no fileType information from this. I can get more accurate responses from using file info and mimetype functions in PHP - but they don't work on $_FILES objects and I'm trying to do this check before I transfer the file to s3 so I don't really want to load it locally.
Can anyone advise if there's something I can to get more accurately report type from $_FILES or is it going to have to load locally in order to run these alternative PHP functions?
finfo is the only way to do this. You cannot rely on information the client sends you, it is far too easy to fake from the client side.
There is no reason that it won't work with $_FILES, you would simply pass $_FILES['files']['tmp_name'] as the file path - this is still a valid file path, and you don't need to call move_uploaded_file() to access the data. Leaving the file in the temp location also has the advantage that it will be destroyed when the script is finished if you haven't done anything with it.
uploading image with file_put_contents make 0 byte file.
here is the code that I use. I extract facebook image url and put it into web server.
$fb_image_url = 'https://example.com/229282.jpg'
$filename = substr($fb_image_url, strrpos($fb_image_url, '/') + 1);
file_put_contents('upload/user_pic/original/'.$filename, file_get_contents($fb_image_url));
after I do this, the server receive file name successfully, but it is 0 bytes.
I checked php.ini, and allow_url_fopen is ON.
uploading folder permission is also fine.
To copy images from facebook, script/php program require permission for same. if program/ FB API dont passes validation/permission check, FB dont allows to download any image.
Its looks like your Application don't have permission to download/copy this image from Facebook that's why your getting 0 bytes.
Try giving PUBLIC access to image and keep FB account logged in while coping image
I just put that URL into the browser:
https://fbcdn-profile-a.akamaihd.net/hprofile-ak-snc4/274661_1171545457_6475606_n.jpg
And received 404 Not Found in response. This would explain why you get empty file locally. I strongly suggest that you load the data first, verify what you received and then, if validation passes, save it locally.
here is the solution.
I had a problem with facebook profile address.
$fb_image_url = 'https://graph.facebook.com/'.$facebook_id.'/picture?type=large';
$filename = $fb_id.'_'.time().'.jpg';
$result = file_get_contents($fb_image_url);
file_put_contents('upload/user_pic/original/'.$filename, $result);
with this_ it worked fine. Yeah! Thank you everyone!
I'm writing a web app that at one point allows a user to upload a photo to a flickr account (mine). I want to do this without saving the intermediate image on the server my web app is on.
What I've got so far is a page which implements phpFlickr and accepts a POST from a simple html form. I use $_FILES['file']['tmp_name'] as the path for phpFlickr to use. Here's the code:
<?php
require_once("phpFlickr.php");
$f = new phpFlickr("apikey", "secret", true);
$_SESSION['phpFlickr_auth_redirect'] = "post_upload.php";
$myPerms = $f->auth("write");
$token = $f->auth_checkToken();
$phid = $f->sync_upload($_FILES['file']['tmp_name']);
echo "Uploading Photo..." . $phid;
?>
I'm guessing that the tmp file is being lost because of the redirect that happens when $f->auth("write") is called, but I don't know. Is there a way to preserve it? Is there any way to do this without saving the file to the server?
Answer: There is No way to directly upload a file to Flickr without saving it as an intermediate file.
I've moved on to using move_uploaded_file() followed by a flickr API call, and its working perfectly.
I've also managed to get it to play nice with the excellent Jquery Uploadify, which lets me send multiple files to it in one go.
I am working with the FaceBook API to upload photos, and the API requires a local file path. As far as I can tell they are handing the request off to CURL like such: upload=#localfilename
But my files don't reside locally, so I am trying to figure out if there is a way to make it work with a remote file....
I tried pointing it to a local file which just did 'echo file_get_contents('some_remote_image.jpg');'
but that didn't work.
Does anyone have any ideas?
Thanks!
You can however link to them eg
<img src="www.mydomain.com"/>
Is it not possible to cache the file on your server and then delete it after upload? I wrote a Flickr -> Facebook Photo Album app that does this very thing.
All right, well if you don't want to do that, you can do this:
Edit the file facebookapi_php5_restlib.php, tracing the photo upload calls down to the actual curl call, which is in:
private function post_upload_request($method, $params, $file, $server_addr = null)
Now the hacky part, instead of passing the filename for $file, pass in an array and then check if its an array in this function. If it is, extract the binary data from it and set it as one of the post parameters. Some curl parameters that you may need can be found here:
http://www.digimantra.com/technology/php/post-pictures-on-twitpic-api-using-php/