Hi all,
Complete newbie here with little PHP knowledge… so please be gentle
OK… I have a website which suppliers upload stocklists to via FTP. A cron job runs hourly on my Ubuntu server to import the datafiles into a MySQL database - which is then presented in a PHP frontend for users to compare pricing. This all works seamlessly and is completely automated.
Here is the twist - one supplier uploads a stock file whos name changes every day - it always starts with their company name but is appended by the date. So as an example the files I receive are;
company 1st July 2019.csv
company 2nd July 2019.csv
company 3rd July 2019.csv
etc.
My import script is obviously needs to know the name of the file to import into the databse. So I can think of two ways of fixing this;
- Change the name of the file to the same thing each day
- Truncate the filename at a certain length and add the extension on the end (eg truncating at 7 would become company.csv every time).
Incidentally the stock files are uploaded into a directory per supplier, eg;
/var/www/html/FTP/companyA
/var/www/html/FTP/companyB
/var/www/html/FTP/companyC
etc
I know that this probably isnt hard - but can anyone help with a solution?
Thanks in advance.