U
U
Username2015-08-06 21:04:27
PHP
Username, 2015-08-06 21:04:27

How to change php file name?

After transferring the site from local to hosting, I was horrified, 60% of the materials do not display pictures, and the point is that the path to the /1.png type file is indicated in the database, but in reality the file name is 1.PNG, it would seem that you rename the database from /1. png to /1.PNG, but 40% of the files have a png extension.
And there are two ways:
1) Run through the directory in ascending order of files and replace the extension in the database if it is not true
2) Or rename PNG files to png
Tell me how any of the two methods can be implemented.

Answer the question

In order to leave comments, you need to log in

5 answer(s)
A
Alexander, 2015-08-06
@dalv_happy

2)

$a = glob('*.PNG');
foreach($a as $name)
{
  $name_new = str_replace(".PNG", ".png", $name);
  rename($name, $name_new);
}

N
Nikita Kamenev, 2015-08-06
@NickStone

Or do not write shitty code and do not take into account the case after the select from the database.

A
AlikDex, 2015-08-06
@AlikDex

stackoverflow.com/questions/11818408/convert-all-f...

T
TyzhSysAdmin, 2015-08-06
@POS_troi

And the whole problem is that when developing on Windows systems, they never think about the fact that register matters in Unix systems;)
I can offer a third option
3) Buy windows hosting
:D

B
belkin-labs, 2015-08-09
@belkin-labs

Download site to local machine, change file names in any available multiple rename tool, upload files back.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question