本文整理汇总了PHP中Uploader::send_file方法的典型用法代码示例。如果您正苦于以下问题:PHP Uploader::send_file方法的具体用法?PHP Uploader::send_file怎么用?PHP Uploader::send_file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Uploader
的用法示例。
在下文中一共展示了Uploader::send_file方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Uploader
$targetPath = "{$upload_base_path}{$ds}{$id}{$ds}";
// Ensure we have somewhere to upload to
// We're grouping uploades by their associated event so
// we're making directories here
shell_exec("mkdir -p {$targetPath}");
$targetFile = $targetPath . $_FILES['file']['name'];
if (!move_uploaded_file($tempFile, $targetFile)) {
$app->log->error("Error saving uploaded file.");
$app->response->status(500);
}
$app->log->error("File Uploaded");
$options = Configuration::get_configuration('upload');
// Step Two: Send the file somewhere and expect a URL back
$uploader = new Uploader($options);
try {
$response = $uploader->send_file($targetFile, $id);
} catch (Exception $e) {
print $e->getMessage();
$app->log->error($e->getMessage());
return;
}
$location = $response['location'];
// we should have the $location of our uploaded file
if (empty($location)) {
throw new Exception("Upload expected an image location");
}
// Step Three: Add the URL of the file as an image for the event
// Lucky us, we just have to call renderImage on the front
// end. That will save the image to the the database.
header("Content-Type: application/json");
echo json_encode(array("location" => $location));