当前位置: 首页>>代码示例>>PHP>>正文


PHP Uploader::send_file方法代码示例

本文整理汇总了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));
开发者ID:lursu,项目名称:morgue,代码行数:31,代码来源:routes.php


注:本文中的Uploader::send_file方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。