`
My Problem is the upload image laravel still error.
Internal server error, IDK where is wrong in my code
I'm using FTP cause it should be upload to external storage
Image intervention stream() facade used for upload image:
http://image.intervention.io/api/stream
$getFile = Image::make($request->file('image')->path())->resize(320, 240);
$image_thumb = $getFile->stream();
Storage::disk('ftp')->put($filenametostore, $image_thumb->__toString());
Related
I'm using Laravel Vapor to host a site. Up until now, I've not had a problem with the lack of a filesystem, but now I've hit a brick wall.
I'm trying to optimize .png and .jpeg files, and the libraries I found require a filesystem to write the compressed files:
Image Optimizer (https://github.com/spatie/image-optimizer)
PHP Image Cache (https://nielse63.github.io/php-image-cache/)
I'm guessing that I can set up an external service that runs on an additional traditional server... But I'd prefer to make it work with Vapor.
Any ideas?
Have you tried using GD Library or Imagick directly?
Using Imagick with files on s3 you can do something like this:
$s3 = \Storage::disk('s3');
$file = $s3->get('tmp/'.$uuid); // assuming Vapor upload to S3 here
$imagick = new \Imagick(); // extension can be added to Vapor.
$imagick->readImageBlob($file);
$imagick->thumbnailImage(200,200);// whatever size you are looking for.
$s3->put('path/on/s3/for/your/optimized/file',$imagick->getImageBlob(),['CacheControl' => 'max-age=10000000, public', 'ACL' => 'public-read']) // whatever options you need
Note both read and write are from/to s3 directly. No need to write to local disk
I'm having problem with my laravel file system CORS, I'm trying to cache the image from the url (which is also my website) in my ionic application but it's failing because of the error. I tried the image from https://reqres.in/api/users/1 and there is no problem caching the image in my ionic application. I guess the problem here is in my laravel website
In one of my current projects I have to save 200+ images in my Ionic App from a request to my server.
The way I handled this problem was converting the image to Base64 using Image Intervention and responding to the request with back to the app to then save the Base64 in the Ionic Storage like so.
Laravel Controller
public function grabImages(Request $request){
$image = (string) Image::make('public/bar.png')->encode('data-url');
$data = {
'base64' : $image,
'file_name' : 'test'
}
return $data;
}
Ionic
After receiving the data you can just store it in the Ionic Storage and access it wherever you would like to, even offline.
To display it all you have to do is set the image source to the Base64.
Using this method also solves a few problems, such as the user cannot see the images in the image gallery, as well as allows you to store them and use them offline for as long as you would like and remove them whenever.
As ImJT said I am using the barryvdh's laravel-cors plugin as well.
Hope this answered your question, good luck!
I have a problem when using cloudinary in codeigniter. At first, i integrate the library by following answers from
Upload image to Cloudinary using PHP Codeigniter
It worked when i uploaded online image. But failed when i tried to upload local image. The error is
Error in loading http://localhost/admin-simple/assets/img/avatar1_small.jpg - 503 Service Unavailable
Here is my code :
Cloudinary::config(array( "cloud_name" => "my_cloud_name", "api_key" => "1234", "api_secret" => "ABCD" ));
$data['upload'] = \Cloudinary\Uploader::upload("http://localhost/admin-simple/assets/img/avatar1_small.jpg");
$this->load->view('partials/sukses_upload_gambar',$data);
Can anyone help me ? Because i've been stuck for hours. Thanks.
According to Cloudinary documentation, when uploading a file from your computer, you should specify the filepath instead of the URL of your local server:
\Cloudinary\Uploader::upload("/home/my_image.jpg")
http://cloudinary.com/documentation/php_integration
I tried to use this code
$image = new ImageManager();
$image = $image->make($path);
and namespace is use Intervention\Image\ImageManager;
and I get this error
localhost is currently unable to handle this request.
what is the problem?
you need to specify which version of intervention you are using.
Still check your namespace it needs Intervention\Image\ImageServiceProvider.
I am developing an API using Codeigniter and I want to let users upload images to my Amazon S3 account. I am using Phils Restserver and Donovan Schönknecht S3 library (for Ci).
It works perfectly to upload a local file to Amazon but how can I get the image file
sent via normal external form?
Using the built in Ci upload library it works fine but then I have to store the files
locally on my own server and I want them on S3. Can the two be combined?
I guess what I am asking is how can I "get" the image file that is sent to the controller
and resize it and then upload it to S3?
Do I perhaps need to temporary save it on the local server, upload it to S3 and then remove it from the local server?
This is my "upload" modal:
// Load the s3 library
$this->load->library('S3');
// Make the upload
if ($this->s3->putObjectFile($args['local'], "siticdev", $args['remote'], S3::ACL_PUBLIC_READ)) {
// Handle success
return TRUE;
} else {
// Handle failure
return FALSE;
}
Thankful for all input!
If I understand you correctly, you want a user to upload an image via a form, resize that image, then transfer that to Amazon S3.
You'll have to store the file locally (at least for a few seconds) to resize it with CI. After you resize it, then you can transfer it to Amazon S3. In your success callback from the transfer, you can delete the image from your server.
You should definitely check out the CI S3 library. The "spark" is available here - http://getsparks.org/packages/amazon-s3/versions/HEAD/show