Beertastic Beertastic - 9 months ago 44
PHP Question

laravel (or core PHP) - Can I get a file from a server, without knowing the file ext?

I made a boo boo....

I built a system that let a user upload assets and track them.
Cool, it works.

I then used the same system to upload site specific assets (logos, employee headshots etc)... and then realized that as they're very static iamges, I don't need to use the asset system.

So now I've a folder on my storage server full of iamges labelled:



where the number is my employee database ref... what my issue is, is that I didn't track whta file type is uploaded...

My options:

  1. Restrict users to only upload one file format

  2. Use PHP to get a file regardless of the file ext...

No 1, I can do.. but I wonder.. is No 2 possible..??

I'm pulling from an S3 bucket if that's of any use?

Answer Source
  $filename = filename without extension ;
  $files=File::glob($storage_path.'/'. $filename.'*');
  if($files) {

$file will contain the filename with extension if it exists