Html-Post Facebook, Html-Post Facebook |
Html-Post Facebook, Html-Post Facebook |
Arimle |
Nov 25 2020, 03:32 AM
Post
#1
|
Group: Members Posts: 3 Joined: 25-November 20 Member No.: 27,653 |
I have an html file that selects a file from the user's computer
CODE <html> <body> <form enctype="multipart/form-data" action="http://localhost/uploader/upload.php" method="POST"> Please choose a photo: <input name="source" type="file"><br/><br/> Say something about this photo: <input name="message" type="text" value=""><br/><br/> <input type="submit" value="Upload"/><br/> </form> </body> </html> When I click the download button, I need to upload this file to Facebook and share this file. On the Internet I found the following code. I'm very little familiar with PHP, but I think this code is closer to my task. CODE <?php //upload.php if(isset($_FILES['photo']) && isset($_POST['message'])){ $uploadfile = './uploads/'.basename($_FILES['photo']['name']); $iStats=getimagesize($_FILES['photo']['tmp_name']); if (isset($iStats['mime']) && $iStats[0]>0) { move_uploaded_file($_FILES['photo']['tmp_name'], $uploadfile); include_once 'fbmain.php'; try{ $uid = $facebook->getUser(); $me = $facebook->api('/me'); $token = $session['access_token'];//here I get the token from the $session array $album_id = '2179901265385';//MY ALBUM ID $facebook->setFileUploadSupport(true); $args = array('message' => $_POST['message']); $args['image'] = '@' . realpath($uploadfile); $data = $facebook->api('/'. $album_id . '/photos?access_token='. $token, 'post', $args); } catch(FacebookApiException $e){ echo "Error:" .$e; } unlink($uploadfile); echo "Success!\n"; } else { echo "Wrong file type!\n"; } } ?> Please help me, what needs to be changed in the code in order to transfer the selected file to Facebook and share this file? Attached File(s) FB1.HTML ( 1.49k ) Number of downloads: 3039 |
Lo-Fi Version | Time is now: 25th September 2024 - 12:50 AM |