Maniruzzaman Akash
Maniruzzaman Akash

Reputation: 5035

File Can't copy from old path to new Path Laravel 5.5 - Time Limit exceeded Error

I want to copy a file from a location to another location in Laravel 5.5.

I've tried,

$old_image = "http://localhost:8000/images/old.jpg";
$new_image = public_path()."/images/new.jpg";

if (! File::copy($old_image , $new_image)) {
    //Error
}

I've got the warning message after 60 seconds.

"Maximum execution time of 60 seconds exceeded"

File is not copied there. What I'm wrong ? Is there a problem to initializing the path or not ?

Please Help someone..

Upvotes: 1

Views: 174

Answers (2)

Divyesh pal
Divyesh pal

Reputation: 947

If you are getting the max_execution_time error then you can set the execution time in your code by setting the value like

ini_set('max_execution_time', 0);

or you can go to your php.ini file search and modify the execution_time over there to how much time you need to execute the action, you can set it to 0 if you want to set it as infinite

Upvotes: 0

Maniruzzaman Akash
Maniruzzaman Akash

Reputation: 5035

So, according to @Maraboc , My problem was to get the old file.

My old file is in the images/requests/old.jpg directory. And I need to assign that using public_path(). Laravel can't move/copy a file from relative path to another.

$old_image = public_path()."/images/requests/old.jpg";
$new_image = public_path()."/images/students/new.jpg";

Thanks, @Maraboc For your commenting and helps to figure out that.

Upvotes: 1

Related Questions