01.
if
(!
is_array
(
$_FILES
[
"photo"
][
'name'
]))
02.
{
03.
$RandomNum
= time();
04.
$random_digit
=rand(0000,9999);
05.
$images
=
$_FILES
[
"photo"
][
"tmp_name"
];
06.
$ImageName
=
str_replace
(
' '
,
'-'
,
strtolower
(
$_FILES
[
'photo'
][
'name'
]));
07.
$ImageType
=
$_FILES
[
'photo'
][
'type'
];
08.
$Imagesize
=
$_FILES
[
'photo'
][
'size'
];
09.
$ImageExt
=
substr
(
$ImageName
,
strrpos
(
$ImageName
,
'.'
));
10.
$ImageExt
=
str_replace
(
'.'
,
''
,
$ImageExt
);
11.
$ImageName
=
str_replace
(
$ImageName
,
$job_no
,
$ImageName
);
12.
$ImageName
= preg_replace(
"/\.[^.\s]{3,4}$/"
,
""
,
$ImageName
);
13.
$NewImageName
=
"Photo_"
.
$ImageName
.
'_'
.
$RandomNum
.
'.'
.
$ImageExt
;
14.
15.
16.
17.
18.
19.
$new_images
=
"Thumbnails_"
.
$ImageName
.
'_'
.
$RandomNum
.
'.'
.
$ImageExt
;
20.
21.
$width
=100;
22.
$size
=
GetimageSize
(
$images
);
23.
$height
=
round
(
$width
*
$size
[1]/
$size
[0]);
24.
$images_orig
= ImageCreateFromJPEG(
$images
);
25.
$photoX
= ImagesX(
$images_orig
);
26.
$photoY
= ImagesY(
$images_orig
);
27.
$images_fin
= ImageCreateTrueColor(
$width
,
$height
);
28.
ImageCopyResampled(
$images_fin
,
$images_orig
, 0, 0, 0, 0,
$width
+1,
$height
+1,
$photoX
,
$photoY
);
29.
ImageJPEG(
$images_fin
,
$output_dir
.
"/"
.
$new_images
);
30.
ImageDestroy(
$images_orig
);
31.
ImageDestroy(
$images_fin
);
32.
33.
if
(
$Imagesize
>
'500000'
){
34.
$width
=1024;
35.
$size
=
GetimageSize
(
$images
);
36.
$height
=
round
(
$width
*
$size
[1]/
$size
[0]);
37.
$images_orig
= ImageCreateFromJPEG(
$images
);
38.
$photoX
= ImagesX(
$images_orig
);
39.
$photoY
= ImagesY(
$images_orig
);
40.
$images_fin
= ImageCreateTrueColor(
$width
,
$height
);
41.
ImageCopyResampled(
$images_fin
,
$images_orig
, 0, 0, 0, 0,
$width
+1,
$height
+1,
$photoX
,
$photoY
);
42.
ImageJPEG(
$images_fin
,
$output_dir
.
"/"
.
$NewImageName
,75);
43.
ImageDestroy(
$images_orig
);
44.
ImageDestroy(
$images_fin
);
45.
46.
}
else
{
47.
move_uploaded_file(
$_FILES
[
"photo"
][
"tmp_name"
],
$output_dir
.
$NewImageName
);
48.
49.
}