Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialShane McC
3,005 PointsCan't upload same photo twice - Laravel 4 Image Intervention
How do I make sure each indivually image gets uploaded? Here's my issue, if I upload an image called "cat.jpg" and then upload another image called "cat.jpg" but there two different pictures the first "cat.jpg" replaces the second "cat.jpg".
How do I make sure this does not happen? I'm using image intervention and laravel 4. Thanks
http://image.intervention.io/ http://laravel.com/
if($validator->passes()){
$image = Input::file('image');
$title = Input::get('title');
$fileName = $image->getClientOriginalName();
$path3 = public_path() . '/img/' . $fileName;
$watermarkPath = public_path() . '/img/watermark.jpg';
$watermarkPath = Image::make($watermarkPath);
// http://image.intervention.io/api/insert
Image::make(
$image->getRealPath())
->resize('200','200')
->insert($watermarkPath, 'bottom-left', 10, 10)
->save($path3);
Thanks
Shane McC
3,005 PointsShane McC
3,005 PointsTo fix this all I did was use the str_random function and I appended the string onto my image
$fileName = str_random(8).$fileName;