receiving and uploading file without saving PHP
i'm using flash to upload image to php script which saves file on same directory and then uploads it to facebook album. That way i'm getting bunch of disk space used. Is there any way to bypass saving and just upload directly?
Script below:
$upload_dir = $_SERVER['DOCUMENT_ROOT'] . dirname($_SERVER['PHP_SELF']) . '/';
$upload_url = "http://".$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']) . '/';
$message ="";
$temp_name = $_FILES['Filedata']['tmp_name'];
$file_name = $_FILES['Filedata']['name'];
$file_name = str_replace("","",$file_name);
$file_name = str_replace("'","",$file_name);
$file_path = $upload_dir.$file_name;
move_uploaded_file($temp_name, $file_path);
and then to upload I'm using:
$attachment = array (
'access_token' => $appAccessToken,
'message'=> "NA开发者_开发百科ME: ".$name.");
$attachment['image'] = '@' . realpath($file_path);
Thanks in advance!
//get it
$upload_dir = $_SERVER['DOCUMENT_ROOT'] . dirname($_SERVER['PHP_SELF']) . '/';
$upload_url = "http://".$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']) . '/';
$message = "";
$temp_name = $_FILES['Filedata']['tmp_name'];
$file_name = $_FILES['Filedata']['name'];
$file_name = str_replace("","",$file_name);
$file_name = str_replace("'","",$file_name);
$file_path = $upload_dir.$file_name;
//save it
move_uploaded_file($temp_name, $file_path);
//upload it to FB
$attachment = array (
'access_token' => $appAccessToken,
'message'=> "NAME: ".$name);
$attachment['image'] = '@' . realpath($file_path);
//more code to upload it....
//delete it
unlink($file_path);
- get it
- save it
- upload it to Fb
- delete it (with
unlink()
function)
I guess, and I'm not sure about that, that you can send an attachment from the client computer (like C:\Folder1\Folder2\Image1.jpg) and you do not have to upload it into a server for sending it as an attachment. Give it a shot.
精彩评论