Search
 
SCRIPT & CODE EXAMPLE
 

PHP

laravel copy image with new name

 
//contact_ids is ['10','11',''12], i mean multiple value;contact_ids data type is json so that we will use json_decode()

$sharedContact = SharedContact::all();
$contacts = Contact::whereIn('id',json_decode($sharedContact->contact_ids))->get();

            foreach ($contacts as $contact){
				// copying the old record
                $sharedContact = $contact->replicate();
                
				//change name for image and saving in local storage
                $newName = 'share_'.time().'_'.$contact->photo;
                $newPathWithName = 'public/photo/'.$newName;
                
                if (Storage::copy('public/photo/'.$contact->photo , $newPathWithName)) {
//                    dd("success");
                    $sharedContact->photo = $newName;
                    $sharedContact->user_id = Auth::id();
                    $result = $sharedContact->save();
                }
                dd($result);
                
            }
Comment

laravel copy image

//$contact->photo is file name with extension -> dljfkaldla.jpg 
$newName = 'copy_'.time().'_'.$contact->photo;
                $newPathWithName = 'public/photo/'.$newName;
                if (Storage::copy('public/photo/'.$contact->photo , $newPathWithName)) {
                dd("success");
                }
Comment

PREVIOUS NEXT
Code Example
Php :: laravel password test 
Php :: Before Action methoond in Yii 1 controller 
Php :: livewire custom attribute 
Php :: laravel collection sort by date 
Php :: laravel combo unique validation 
Php :: wc php get shipping methods 
Php :: reindex after post api magento 2 
Php :: "IlluminateDatabaseEloquentMassAssignmentException" 
Php :: strpos 
Php :: phpdoc @var 
Php :: blade directive 
Php :: laravel get unique data by column and order by 
Php :: canany else 
Php :: php get file from another server 
Php :: php check if input is a positive integer 
Php :: redirect to intent url after login laravel 
Php :: isset in php 
Php :: square root 
Php :: wp_delete_attachment unlink 
Php :: document ready wordpress 
Php :: return pdft download and back with msg in laravel 
Php :: php if null then 0 
Php :: php enablem mod 
Php :: how to use or where in laravel 
Php :: wordpress if page 
Php :: php response image 
Php :: phpmailer send email to multiple addresses 
Php :: Php OOP function CRUD 
Php :: base64_img 
Php :: laravel blade @if 3 varabile 
ADD CONTENT
Topic
Content
Source link
Name
7+8 =