Simple File Upload Routine...

I am trying to set a routine to upload a set of files to my server. Unlike most of the file upload routines that are out there, I need one that sends the same files each time… IE: 1.jpg, 2.jpg, 3.jpg, etc… Same filenames every time. I found a routine that uses the Browse for file name, but have not found out how to make it to where I can automatically populate the fields… Any help with this would be appreaciated.

John

Hi John,

Try the rename() function.


$id=0;

for($i=0; $i<count($_FILES[userfile][tmp_name]); $i++)

{

 $id=$id+1;  

 $name = $_FILES[userfile][name][$i];

 @rename($name, $id . ".jpg");

}

Assuming that ‘userfile’ is the name of your input field and that you are uploading multiple files.

Hopefully this gives you an idea.

Sponsor our Newsletter | Privacy Policy | Terms of Service