Jump to content

Renaming a file whilst uploading, cant get the mime type to work


Recommended Posts

Hi again folks, I have an upload script for avatars/images, but I dont want them to retain their original name I want them to use the session id, now I can get the files to upload with the session ID but I cant get the extension to go on, any help?
I have currently:

[code]$ext = $_FILES['avatar']['type'];
if (move_uploaded_file($_FILES['avatar']['tmp_name'],$upload_dir.session_id() .".". $ext)) {
[/code]
nevermind i actually found it in the membership tutorial, well the command, then used it for my own diabolical ends :) if anyone wants to know

[code]$ext = strrchr($_FILES['avatar']['name'], ".");
if (move_uploaded_file($_FILES['avatar']['tmp_name'],$upload_dir.session_id() .".". $ext)) {
[/code]
I would still re-consider ussing the session id in teh file name. Remeber these are generated randomly - they ARE NOT unique to each user - each time you login in the seesion id will in 9 zillion cases be different to the last session id you had.

Now if you set a session variable called ID and set that to the unique identifier for the user form your database - that would be a different matter and your system would then work.
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.