我想使用此参数在laravel 4中创建一个路径
$options = [ 'gs_bucket_name' => 'images_upload'];
$upload_url = CloudStorageTools::createUploadUrl('/upload_handler.php', $options);
表示指向此$ upload_url的路由。 createUploadUrl在upload_handler.php上发布帖子并将数据存储到gs bucket。我的问题是没有执行帖子,因为应该在路由上指定upload_url。我怎么能这样做?
upload_handler.php
<?php
var_dump($_FILES);
?>
视图
{{ Form::open(array('action' => 'upload_handler','files' => true)) }}
{{ Form::file('file') }}
<br>
{{ Form::submit('Add Photo', array('class' => 'btn btn-primary' )) }}
{{ Form::close() }}
路线
Route::group(array('before' => 'auth'), function() {
Route::post('upload_handler', function($upload_url = null) {
$options = [ 'gs_bucket_name' => 'images_upload'];
$upload_url = CloudStorageTools::createUploadUrl('/upload_handler.php', $options);
return $upload_url;
});
});
但这只是返回网址。怎么做帖子?
在纯php中,代码是:
require_once 'google/appengine/api/cloud_storage/CloudStorageTools.php';
use google\appengine\api\cloud_storage\CloudStorageTools;
$options = [ 'gs_bucket_name' => 'images_upload'];
$upload_url = CloudStorageTools::createUploadUrl('/upload_handler.php', $options);
?>
<div class="body">
<form action="<?php echo $upload_url ?>" enctype="multipart/form-data" method="post">
<input type="file" name="uploaded_files" size="40">
<input type="submit" value="Send">
</form>
</div>
答案 0 :(得分:0)
你的问题有点模糊我害怕,但我认为你所追求的是Redirect::to
。这样您就可以将post
请求重定向到CloudStorageTools
类上方法生成的网址。
return Redirect::to($upload_url);