class.upload.php is a powerful and mature PHP class to manage uploaded files, and manipulate images in many ways. The script is available under a GPL license.
I am trying to assign the source filename to a PHP variable so that I can add it to a database. I see that file_name_src contains this information but cannot figure out how to assign it. I tried $photo = $handle->file_name_src ; but that did nothing.Reply
Re: Assigning source image's filename to PHP variable new!
I am trying to assign the source filename to a PHP variable so that I can add it to a database. I see that file_name_src contains this information but cannot figure out how to assign it. I tried $photo = $handle->file_name_src ; but that did nothing.
$handle = new upload($_FILES['photo']); if ($handle->uploaded) { $handle->file_new_name_body = $filename; $handle->file_auto_rename = true; $handle->image_resize = true; $handle->image_x = 400; $handle->image_y = 400; $handle->image_ratio = true; $handle->image_convert = 'jpg'; $handle->jpeg_quality = 95; $handle->process('../../../gallery/photos'); $handle->file_new_name_body = $filename . "_thumb"; $handle->file_auto_rename = true; $handle->image_resize = true; $handle->image_x = 120; $handle->image_y = 120; $handle->image_ratio = true; $handle->image_convert = 'jpg'; $handle->jpeg_quality = 95; $handle->process('../../../gallery/photos/thumbs'); if ($handle->processed) { $photo = $handle->file_dst_name_body; $handle->clean(); $addPhotoSql = "INSERT INTO images (caption, filename, album) VALUES ('$caption', '$photo', '$albumTitle')"; $addPhoto = mysql_query($addPhotoSql) or die(mysql_error()); header('Location: display_album.php?album=' . $url . "#thumbs"); } else { echo 'error : ' . $handle->error; } } }session_start()'
$_SESSION ['imgURL'] = $filename . "_thumb";
Hey, instead of the file_new_name_body, use the file_body_name_add = "_thumb"
that will add the _thumb like this file_thumb.jpg
the way you have it will look like this filenamejpg_thumb.jpg
hope this helps