There is a physical path from the root:

/upload/user/2014/14/14/pid_113456/avatar/2132434242.jpg 

You need to get the output:

 /img/113456/2132434242.jpg 

when taking into account that /2014/14/14/ - folders created by time, year, month, day. In other words, there are many of them.

The fact is that the project is very large (a startup), and a lot of perezalivat ... Hellish work. Needs have changed - and now it is necessary to shorten the path.

  • @ pavlok2008, If you are given an exhaustive answer, mark it as correct (click on the check mark next to the selected answer). - Vitalina

1 answer 1

I am afraid that this will not work out for you, since part / 2014/14/14 / is not transmitted anywhere in the URL and get it from anywhere.

I think you better write a PHP script that would recursively run through your directories and physically transfer your files to new directories.

  • Thanks, I already did. I just thought, maybe, somehow from under the folders to go to the rewright base - cut to the root, but again you will not list all the folders and you will get the gluing. Definitely: I rewrote the script that fixed everything, only it took me half the night. - pavlok2008