image - Get first file in directory PHP -


i want first file in directory using php.

i trying make function users on website can change profile picture. show profile picture on profile page want first image in profile picture folder. want image have uploaded, regardless of file type. have made when upload new picture old 1 deleted, 1 file in folder. how do this?

you can first file in directory this

$directory = "path/to/file/"; $files = scandir ($directory); $firstfile = $directory . $files[2];// because [0] = "." [1] = ".."  

then open fopen() can use w or w+ modes:

w open writing only; place file pointer @ beginning of file , truncate file 0 length. if file not exist, attempt create it.


Comments

Popular posts from this blog

matlab - error with cyclic autocorrelation function -

django - (fields.E300) Field defines a relation with model 'AbstractEmailUser' which is either not installed, or is abstract -

c# - What is a good .Net RefEdit control to use with ExcelDna? -