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
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!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.