Image

Imageangelina_zooma wrote in Imagephp 😡frustrated

Image upload VS Windows Server

I have an image uploading script that works fine on my server. However I need to transfer this stuff over to the client's server, which is Windows.

sigh.

Everything seems to be working except for the actual uploading portion, which throws me an error

specifically this part:

if(move_uploaded_file ($userfile, $add)){
chmod("$add",0777);
}else{echo "Failed to upload file Contact Site admin to fix the problem";
exit;}

which I'm assuming is because windows servers don't play with chmod, but that's the extent of my knowledge on this issue. I spoke with the server admin and the said they set the entire site to open (which is what I want?)

so the permissions may be right, but possibly the server doesn't know how to deal with this php function?

I don't know, but I'm banging my head against the wall. I'll include the rest of the script under the cut. Any help would be much appreciated!


$special = array('$',',',' ','#',')','(','[',']',':');
$key1 = $_POST['key1'];
$userfile_name = $_FILES['userfile']['name'];
$userfile_size = $_FILES['userfile']['size'];
$userfile_type = $_FILES['userfile']['type'];
$userfile_tmpname = $_FILES['userfile']['tmp_name'];
$userfile_error = $_FILES['userfile']['error'];

/* Check to see if file is over 300kb */
if ($userfile_size >300000){
header("location:images.php?msg=toobig&key1=$key1");exit;
}
/* Check to see if file is a jpg or gif */
if (!($userfile_type =="image/pjpeg" OR $userfile_type=="image/gif" OR $userfile_type=="image/jpeg")){
header("location:images.php?msg=wrongfile&key1=$key1");exit;
} else {}

/* Check for image size */

$size = getimagesize($userfile);
if ($size[0] >= 200 || $size[1] >= 200) {
if($size[0] < $size[1]) {
$n_height = 200;
$n_width = $size[0] * ($n_height/$size[1]);
} else {
$n_width = 200;
$n_height = $size[1] * ($n_width/$size[0]);
}
} else {
$n_width = $size[0];
$n_height = $size[1] * ($n_width/$size[0]);
}
/* removies spaces and characters from filename and adds listing ref to beginning of file name */
$userfile_name = str_replace($special,'',$userfile_name);
$userfile_name = $key1 . "_" . $userfile_name;

$add="../gallery/$userfile_name"; // the path with the file name where the file will be stored, upload is the directory name.

if(move_uploaded_file ($userfile, $add)){
chmod("$add",0777);
}else{echo "Failed to upload file Contact Site admin to fix the problem";
exit;}


/* Thumbnail Generation */
$tsrc="../gallery/thumbnails/$userfile_name"; // Path where thumb nail image will be stored

if (@$userfile_type=="image/gif"){
$im=ImageCreateFromGIF($add);
$width=ImageSx($im); // Original picture width is stored
$height=ImageSy($im); // Original picture height is stored
$newimage=imagecreatetruecolor($n_width,$n_height);
imageCopyresampled($newimage,$im,0,0,0,0,$n_width,$n_height,$width,$height);
if (function_exists("imagegif")) {
Header("Content-type: image/gif");
ImageGIF($newimage,$tsrc);
}
elseif (function_exists("imagejpeg")) {
Header("Content-type: image/jpeg");
ImageJPEG($newimage,$tsrc);
}
chmod("$tsrc",0777);
}
////////////// starting of JPG thumb nail creation//////////
if($userfile_type=="image/pjpeg" || $userfile_type=="image/jpeg" ){
$im=ImageCreateFromJPEG($add);
$width=ImageSx($im); // Original picture width is stored
$height=ImageSy($im); // Original picture height is stored
$newimage=imagecreatetruecolor($n_width,$n_height);
imageCopyresampled($newimage,$im,0,0,0,0,$n_width,$n_height,$width,$height);
ImageJpeg($newimage,$tsrc);
chmod("$tsrc",0777);
}
//////////////// End of JPG thumb nail creation //////////

if ($size[0] >= 640 || $size[1] >= 480) {
if($size[0] < $size[1]) {
$l_height = 640;
$l_width = $size[0] * ($l_height/$size[1]);
} else {
$l_width = 640;
$l_height = $size[1] * ($l_width/$size[0]);
}


$recopy="gallery/$userfile_name"; // Path where thumb nail image will be stored

if (@$userfile_type=="image/gif"){
$im=ImageCreateFromGIF($add);
$width=ImageSx($im); // Original picture width is stored
$height=ImageSy($im); // Original picture height is stored
$newimage=imagecreatetruecolor($l_width,$l_height);
imageCopyresampled($newimage,$im,0,0,0,0,$l_width,$l_height,$width,$height);
if (function_exists("imagegif")) {
Header("Content-type: image/gif");
ImageGIF($newimage,$recopy);
}
elseif (function_exists("imagejpeg")) {
Header("Content-type: image/jpeg");
ImageJPEG($newimage,$recopy);
}
chmod("$recopy",0777);
}
////////////// starting of JPG thumb nail creation//////////
if($userfile_type=="image/pjpeg" || $userfile_type=="image/jpeg" ){
$im=ImageCreateFromJPEG($add);
$width=ImageSx($im); // Original picture width is stored
$height=ImageSy($im); // Original picture height is stored
$newimage=imagecreatetruecolor($l_width,$l_height);
imageCopyresampled($newimage,$im,0,0,0,0,$l_width,$l_height,$width,$height);
ImageJpeg($newimage,$recopy);
chmod("$recopy",0777);
}
//////////////// End of JPG thumb nail creation //////////
} else {}