doctorbill
asked on
php file upload
In the attached file I have the following code:
-------------------------- -
$formfile = "";
if($_FILES['art_Thumb'] && $_FILES['art_Thumb']['size '] > 0){
$uploaddir = "images/artists/thumb/"; //folder in which to put the file
$ori_name = $_FILES[art_Thumb][name];
$tmp_name = $_FILES[art_Thumb][tmp_nam e];
$src = imagecreatefromjpeg($tmp_n ame);
list($width,$height) = getimagesize($tmp_name);
//landscape
if ($width > $height) {
$pwidth = 450;
$newwidth = $pwidth;
$newheight = ($height/$width)*$pwidth;
}
//
//portrait
if ($height > $width) {
$pwidth = $width;
$newheight = 450;
$newwidth = ($width/$height)*$newheigh t;
}
//
$tmp = imagecreatetruecolor($neww idth,$newh eight);
imagecopyresampled($tmp,$s rc,0,0,0,0 ,$newwidth ,$newheigh t,$width,$ height);
$newfile = $uploaddir.$ori_name;
imagejpeg($tmp,$newfile,10 0);
chmod($newfile,0777);
}
-------------------------
This is working firn for most xxx.jpg images but some images are just not being uploaded. The ones not being uploaded are still xxx.jpg and I cannot see what the problem is. All images are always > 1000 pixels wide
Help Help please
frm-artgallery.php
--------------------------
$formfile = "";
if($_FILES['art_Thumb'] && $_FILES['art_Thumb']['size
$uploaddir = "images/artists/thumb/"; //folder in which to put the file
$ori_name = $_FILES[art_Thumb][name];
$tmp_name = $_FILES[art_Thumb][tmp_nam
$src = imagecreatefromjpeg($tmp_n
list($width,$height) = getimagesize($tmp_name);
//landscape
if ($width > $height) {
$pwidth = 450;
$newwidth = $pwidth;
$newheight = ($height/$width)*$pwidth;
}
//
//portrait
if ($height > $width) {
$pwidth = $width;
$newheight = 450;
$newwidth = ($width/$height)*$newheigh
}
//
$tmp = imagecreatetruecolor($neww
imagecopyresampled($tmp,$s
$newfile = $uploaddir.$ori_name;
imagejpeg($tmp,$newfile,10
chmod($newfile,0777);
}
-------------------------
This is working firn for most xxx.jpg images but some images are just not being uploaded. The ones not being uploaded are still xxx.jpg and I cannot see what the problem is. All images are always > 1000 pixels wide
Help Help please
frm-artgallery.php
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
sorry - found it
ASKER
Ray:
I found the issue with my script:
this part caused a problem is the image was a perfect square:
if ($height > $width)
Changing it to if ($height >= $width) solved the problem
On another note - re. the redirect url issue you very kindly sorted out for me yesterday::
$redirect = $redirect
= 'frm_artgallery.php?'
. 'artist_added='
. urlencode($_POST['art_Nme' ])
. '&'. 'image_added='
. urlencode($_POST['art_titl e'])
;
This works if the image name does not have a space in it: image2.jpg
If it does have a space it does not work: image 2.jpg
Can you suggest a fix please - I realise that you have already answered this
I found the issue with my script:
this part caused a problem is the image was a perfect square:
if ($height > $width)
Changing it to if ($height >= $width) solved the problem
On another note - re. the redirect url issue you very kindly sorted out for me yesterday::
$redirect = $redirect
= 'frm_artgallery.php?'
. 'artist_added='
. urlencode($_POST['art_Nme'
. '&'. 'image_added='
. urlencode($_POST['art_titl
;
This works if the image name does not have a space in it: image2.jpg
If it does have a space it does not work: image 2.jpg
Can you suggest a fix please - I realise that you have already answered this
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Solution
ASKER