Jump to content

changing uploaded file name


garydt

Recommended Posts

I've got-

$uploadsDirectory = './uploads/'; 
//Upload image
$uploadFilename = $uploadsDirectory.$a.$fieldname['name'];

$a is a random generated  number.

 

Then the script calls a function to resize the image and saves it in the smallpics folder -

if(imagejpeg($thumb, "smallpics/".$a.$name, 80)) { //image-resource, filename, quality
			return 1;
		}

But it doesn't keep the generated number, it just saves it as the orignal file name. Why is this?  Shall i post the full function script?

 

Link to comment
https://forums.phpfreaks.com/topic/61231-changing-uploaded-file-name/
Share on other sites

Why is it that you go to the trouble of creating a variable to hold your new file name, "$uploadFilename" but your IF statement tests

 

(..smallpics/".$a.$name..)

 

Shouldn't it be:

 

if(imagejpeg($thumb, "$uploadFilename, 80)) { //image-resource, filename, quality
			return 1;
		}

 

That might help a bit, sorry if it doesn't!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.