Wednesday, 15 August 2012

php - laravel deployed on google app engine doesn't upload files -



php - laravel deployed on google app engine doesn't upload files -

i trying upload file, using laravel 4 , deploy on google app engine. locally file upload works, when deploy google app engine doesn't. here code:

view:

{{ form::model($v, array('files' => true,'route' => array('upload.image', $v->id),'method' => 'post','class'=>'form-horizontal','id'=>'upload-images')) }} {{ form::file('image') }} <br> {{ form::submit('add photo', array('class' => 'btn btn-primary' )) }} {{ form::close() }}

controller

$file = input::file('image'); dd($file); $destinationpath = 'img_gallery/'; $extension = $file->getclientoriginalextension(); $filename = 'img_' . $id . '.' . $extension; $file->move($destinationpath, $filename); $car = car::find($id); $car->pic = $filename; $car->save(); homecoming redirect::to('/');

and displays array file attr. when deployed google app engine code returns null. after readin google app engine documentation php understood problem in google app engine can't write filesystem app, , in this link found code php without laravel , tried combine mine below:

upload_test.blade.php

require_once 'google/appengine/api/cloud_storage/cloudstoragetools.php'; utilize google\appengine\api\cloud_storage\cloudstoragetools; $options = [ 'gs_bucket_name' => 'images_upload']; $upload_url = cloudstoragetools::createuploadurl('upload.handler', $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>

controller

public function upload_image($id) { $file = input::file('image'); dd($file); }

route

route::group(array('before' => 'auth'), function() { route::post('upload_handler', array('as' => 'upload.handler', 'uses' => 'carcontroller@upload_handler')); });

controller

public function upload_handler() { var_dump($_files); }

but displays:

symfony \ component \ httpkernel \ exception \ methodnotallowedhttpexception

which know error because form post not pointing route, instead variable. image stored in google app engine problem code doesn't post controller in order save path of file in db. have tried other ways no result. followed step step section 6 in this. furthermore tried ajessup package no result.

with line:

$upload_url = cloudstoragetools::createuploadurl('upload.handler', $options);

the first arg should url-- seek removing quotes (assuming upload.handler points want to), or seek replacing arg actual url app should redirect to.

php google-app-engine laravel

No comments:

Post a Comment