Hi All,
I have a work order form that our employees will use to order website changes and I let them upload attachments also. I am appending the work order id to the beginning of the files names. IE 123-image.jpg etc.
Here is how I am uploading the files.
$ID = mysql_insert_id(); //get the id of the last to append to the beginning of the filenames
$filename1 = "/path to directory/staff/uploads/" . $ID . "-" . $FILE1_name ;
$filename2 = "/path to directory/staff/uploads/" . $ID . "-" . $FILE2_name ;
@copy("$FILE1" , $filename1);
@copy("$FILE2" , $filename2);
And I can read them back as such. (thanks to Bpat's post)
$list = ftp_nlist($ftp, $dir);
foreach($list as $file)
{
if(!is_dir($file) && !is_dir($dir.'/'.$list))
echo '<a href="path to directory/staff/uploads/', $dir, '/', $file, '">', $file, '</a>';
}
But that would list all the files. I want to limit it to the files with the same $ID at the beginning of the name. I would imagine an 'explode' might work, but I am not clear on coding that.
Any suggestions, or has somone seen a post that does that already?
Thanks in advance.
Don