The Laracast regarding images is invalid for 5.3 as the upload simply becomes:
if ( isset($request->image) ) {$path = $request->file('image')->store('public/users');
This is fine and I store $path in a db. Now I want to also add a thumbnail from this so I added:
Image::make($request->image)->fit(200)->save()
but I get NotSupportedException in AbstractEncoder.php line 150: Encoding format (tmp) is not supported.
Help please!
Related
I'm using stripe to get invoice
I need to store this invoice in my public storage folder - I'm using laravel
stripe does not return pdf file path like this - http://localhost/app/invoice.pdf
instead of that
they provide a url like this - https://pay.stripe.com/invoice/acct_1sflasjfmsklagbs/test_alkfnsajklgdbnajkgsbnajkfbsuayasgtjbwq8tuy23690q8319qr8busajvbssavkjsabngukwjqhr82rhadsawoilafkn/pdf?s=ap
so when you enter above url - it generates a pdf dynamically
I tried this and it works if you have direct path of pdf file
$contents = file_get_contents('http://localhost/app/invoice.pdf');
\Storage::disk('public')->put('filename.pdf', $contents);
but below given code does not work
$contents = file_get_contents('https://pay.stripe.com/invoice/acct_1sflasjfmsklagbs/test_alkfnsajklgdbnajkgsbnajkfbsuayasgtjbwq8tuy23690q8319qr8busajvbssavkjsabngukwjqhr82rhadsawoilafkn/pdf?s=ap');
\Storage::disk('public')->put('filename.pdf', $contents);
anyone can please assist here?
I install the Laravel file manager package in my app. but already I cant use thumbnail images in the blog.
How can I get an image thumbnail of uploaded photos when I use Laravel file manager?
After much searching, I realized that such a function does not exist (at least until the time of writing this message).
I defined a function in the helper that returns the address of the thumbnail from the URL of the original image.
The reader should note that these definitions may differ based on the setting of parameters for another person.
function LMFThums($url)
{
$url2= str_replace(basename($url) , '', $url ) ;
$url2=$url2.'thumbs/'.basename($url);
return $url2 ;
}
I want to compress the uploaded image and store the base64 of the image in the database. Every time I google the question I always gets the idea to use the image stored in a certain path. I'm using intervention/image package
I have tried this code
$img = Image::make($request->photo)->resize(300, 200);
//get the extension
$type = $request->file('photo')->getClientOriginalExtension();
//convert it into the base64.
$base64 = 'data:image/' . $type . ';base64,' . base64_encode(file_get_contents($img));
I want to store the photo in the database after compressing and converting into the base64 format. Error that I got
You need not write any compression or conversion code.
Try adding encode('data-url')
I hope it works.
$img = Image::make($request->photo)->resize(300, 200)->encode('data-url');
I am new in laravel currently i have task which is based on PDF ..
Like :
Mearge PDF
Create PDF ,
Convert PDF etc.
But problem is this when i am search on google than there is PDF merger but i don't know how to configure PDF merger or any other Github code in laravel.
Please help. I am always appreciate.
Thanks
Link where i found some code : https://github.com/clegginabox/pdf-merger
$pdf = new \Clegginabox\PDFMerger\PDFMerger;
$pdf->addPDF('samplepdfs/one.pdf', '1, 3, 4');
$pdf->addPDF('samplepdfs/two.pdf', '1-2');
$pdf->addPDF('samplepdfs/three.pdf', 'all');
//You can optionally specify a different orientation for each PDF
$pdf->addPDF('samplepdfs/one.pdf', '1, 3, 4', 'L');
$pdf->addPDF('samplepdfs/two.pdf', '1-2', 'P);
$pdf->merge('file', 'samplepdfs/TEST2.pdf', 'P');
// REPLACE 'file' WITH 'browser', 'download', 'string', or 'file' for output options
// Last parameter is for orientation (P for protrait, L for Landscape).
// This will be used for every PDF that doesn't have an orientation specified
If I understand your question right you just need to add "clegginabox/pdf-merger": "dev-master" to your composer.json in the "require" section found in your laravel project base path. And than run composer update from your console. If you haven't configured composer read through https://getcomposer.org/ and or listen to https://laracasts.com/series/laravel-5-from-scratch its free.
i actually use this one:
https://github.com/LynX39/lara-pdf-merger/blob/master/README.md
if you need more help please let me know
How to populate image field value with drupal_execute.
for ex my content type (test) has two additional fields
1. photo (image filed),
2. phid (text field)
for phid $form_state['values']['field_phid'][0]['value'] ='14'; . how to populate photo which is image field type
If the file is already uploaded to Drupal and has a file ID (fid) then you can just do
$form_state['values']['field_image_filed'][0]['fid'] = 17; //where 17 is the Drupal file ID of the file you want input
If the file isn't already uploaded it's a lot trickier. You'll first need to programmatically create the file. I can't walk you through it off-hand but a good place to look for a template as to how it should be done is the file_service_save() function in the Services module's file_service.inc:
http://drupalcode.org/viewvc/drupal/contributions/modules/services/services/file_service/file_service.inc?revision=1.1.2.7.2.3&view=markup&pathrev=DRUPAL-6--2-2
To be clear: I'm not saying you'll use file_service_save() to accomplish the upload, but that that code shows you what needs to be done. It will show you how to save the file to the server using file_save_data(), record the file to the Drupal "files" table, then call hook_file_insert to notify other modules that a file's been saved.
i found the solution as below . i dont know pros and cons but it works fine for me.
$image = "*******/test.jpg";
$field = content_fields('field_img', 'img_test');
$validators = array_merge(filefield_widget_upload_validators($field), imagefield_widget_upload_validators($field));
$files_path = filefield_widget_file_path($field);
$form_state['values']['field_img'][]= field_file_save_file($image, $validators, $files_path, FILE_EXISTS_REPLACE);