Jump to content

does anyone in here uses verot.net?...


rootKID

Recommended Posts

hello again, since im not sure this is php coding related, ill just go ahead and type in here.correct me if im wrong.. well, im using latest version of verot.net.its a script created for resize pictures and stuff like that, i have used it ALOT in the past.so i was thinking of using it for a project. and everything works just fine as i can see for now.all but the picture names. when i am uploading a picture, i would like to change the name to the user_id given in the database. i DO had succes with this also on the upload, but the trouble is with the picture.i just CANT in anyway and anyhow i try to change the freaking name once its moving to my server. its keeping the same name, and its pretty annoying -.-'... any ideas?...code below:

if(!empty($_FILES['user_picture']))//allways form name...{$handle = new Upload($_FILES['user_picture']);//starting picture uploader..if ($handle->uploaded){  $handle->image_resize  = true;  $handle->image_ratio  = false;  //$handle->image_convert   = gif;//a different pic format...  $handle->image_x    = 100; //Width in Pixels...  $handle->image_y    = 100; //Height in Pixels...   $handle->Process('user_pics/');  $id = mysql_insert_id();//id just given in the database...  //$image = $handle->file_dst_name;//avatar with real name...  $image = $handle->file_new_name_body = $id;//avatar with changed name... (DOSENT WORK...)  //mysql_query("INSERT INTO users (user_avatar) VALUES ('$image')");  mysql_query("UPDATE users SET user_avatar = '$image' WHERE u_id = '$id'");}}//end empty statement...

thanks ALOT in advance!...

Link to comment
Share on other sites

Have you tried something like:

$image = $handle->file_new_name_body .  $id; // concat the image file name to the user id and set it to $image. 

But this can probably produce something like: mypic.jpg24. So you might want to try:

$image =   $id  . '-' . $handle->file_new_name_body; // this can look like:  24-mypic.jpg; remove the '-' if you want but figured be a good idea if you ever have to explode the image file name where you can use the '-' as a dilimiter to extract the user id or just the image name for example. 

I would change the picture name before uploading/moving it to your upload directory. If you want to rename after, you might have to use the rename() function

Link to comment
Share on other sites

ahh.. thanks alot!, might just work. one more question...if i would like JUST to have the id as the name, would that be possible?.. AND with the actual image format?... right now this is how its inserting into the DB: id=14... but i need it to be like this: id=14.jpg... and same thing would be needed on the image name..so if i wrote something like: $image = $handle->$id;//avatar with changed name... you think it would be working?... cos i still need the pic format into the DB itself, and the id number of the current user...wich so far has been a succes... just without the format...

Edited by rootKID
Link to comment
Share on other sites

hmm... sorry, Download Link: http://www.mediafire.com/?ccec1ik5eiusqxw but you should know, its a file on 5000 lines...so open on your own risk, hehe :P...

Link to comment
Share on other sites

Just set file_new_name_body before calling process. After you call process you won't be able to read any information about the uploaded file from the class, it resets all of the properties after process finishes. If you want to get the original name or extension or whatever else then you need to get that before you call process.

Link to comment
Share on other sites

hello all. sorry for late reply, i have finded the solution.a pretty simple one also actually... but im in schools right now, so will post it here once i am home. in case someone in here wonna have the solution till later on with their own projects :)...

Link to comment
Share on other sites

as promissed, a little late. but here is the solution:

if(!empty($_FILES['user_picture']))//allways form name...{$handle = new Upload($_FILES['user_picture']);//starting picture uploader..$id = mysql_insert_id();//id just given in the database...$handle->file_new_name_body = $id;//avatar with changed name...if ($handle->uploaded){  $handle->image_resize  = true;  $handle->image_ratio  = false;  //$handle->image_convert   = gif;//a different pic format...  $handle->image_x    = 100; //Width in Pixels...  $handle->image_y    = 100; //Height in Pixels...   $handle->Process('user_pics/');  $image = $handle->file_dst_name;//avatar with uploaded file name...  //mysql_query("INSERT INTO users (user_avatar) VALUES ('$image')");  mysql_query("UPDATE users SET user_avatar = '$image' WHERE u_id = '$id'");}}//end empty statement...

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...