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.
The code upload images perfectly. When I use "image upload" filed the code upload 2 files to my server. One of is my original file and the other is resized file. I want to write BOTH names and paths to mysql database. Original uploaded file name and resized file name. But it always write the resized name only.
And here is my codes beow:
This is the upload.php part of the code;
// we create an instance of the class, giving as argument the PHP object
// corresponding to the file field from the form
// All the uploads are accessible from the PHP object $_FILES
$handle = new Upload($_FILES['my_field']);
// then we check if the file has been uploaded properly
// in its *temporary* location in the server (often, it is /tmp)
if ($handle->uploaded) {
// yes, the file is on the server
// below are some example settings which can be used if the uploaded file is an image.
$handle->image_resize = true;
$handle->image_ratio_y = true;
$handle->image_x = 300;
// now, we start the upload 'process'. That is, to copy the uploaded file
// from its temporary location to the wanted location
// It could be something like $handle->Process('/home/www/my_uploads/');
$handle->Process($dir_dest);
// we check if everything went OK
if ($handle->processed) {
// everything was fine !
echo 'file uploaded with success';
$info = getimagesize($handle->file_dst_pathname);
echo ' ' . $info['mime'] . ' - ' . $info[0] . ' x ' . $info[1] .' - ' . round(filesize($handle->file_dst_pathname)/256)/4 . 'KB';
echo ' link to the file just uploaded: '.$dir_pics.'/' . $handle->file_dst_name . '';
} else {
// one error occured
echo 'file not uploaded to the wanted location';
echo ' Error: ' . $handle->error . '';
}
// we now process the image a second time, with some other settings
$handle->image_resize = true;
$handle->image_ratio_crop = true;
$handle->image_y = 150;
$handle->image_x = 120;
$handle->image_border = 5;
$handle->image_border_color = '#FF0000';
$handle->file_name_body_pre = 'thumb_';
$handle->Process($dir_dest);
// we check if everything went OK
if ($handle->processed) {
// everything was fine !
echo 'file uploaded with success';
$info = getimagesize($handle->file_dst_pathname);
echo ' ' . $info['mime'] . ' - ' . $info[0] . ' x ' . $info[1] .' - ' . round(filesize($handle->file_dst_pathname)/256)/4 . 'KB';
echo ' link to the file just uploaded: '.$dir_pics.'/' . $handle->file_dst_name . '';
} else {
// one error occured
echo 'file not uploaded to the wanted location';
echo 'Error: ' . $handle->error . '';
}
// we delete the temporary files
$handle-> Clean();
} else {
// if we're here, the upload file failed for some reasons
// i.e. the server didn't receive the file
echo 'file not uploaded on the server';
echo ' Error: ' . $handle->error . '';
}
And this is the index.php which is write data in mysql:
Here is my problem:
The code upload images perfectly. When I use "image upload" filed the code upload 2 files to my server. One of is my original file and the other is resized file. I want to write BOTH names and paths to mysql database. Original uploaded file name and resized file name. But it always write the resized name only.
And here is my codes beow:
This is the upload.php part of the code;
And this is the index.php which is write data in mysql:
I know there is several posts about that issue guys and I try all of them. It still doesn't work well.
Please, Please help or I'm goin' CRAZYYY :)
Thanks already
BYE