I've found this to be quite useful in handing uploaded files through HTTP. You can use this to move the file from your /tmp folder to a folder on your site that isn't mode 777. The concept is simple. It connects to your FTP server and puts the file in the folder of your choice. Usage:
ftp_copy("/tmp/tmpfile", "public_html/uploads");
<?php
function ftp_copy($source_file, $destination_file)
{
$ftp_server = 'ftp.server.com';
$ftp_user = 'login';
$ftp_password = 'password';
$conn_id = ftp_connect($ftp_server);
$login_result = ftp_login($conn_id, $ftp_user, $ftp_password);
if((!$conn_id) || (!$login_result))
{
echo "FTP connection has failed!";
echo "Attempted to connect to $ftp_server for user $ftp_user";
}
$upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY);
ftp_close($conn_id);
if(!$upload)
{
echo "FTP copy has failed!";
return false;
}
else
{
return true;
}
}
?>