beermaker74 Posted February 6, 2007 Share Posted February 6, 2007 I have this basic script that I am trying to work with. It works fine on my local machine. But when I upload itto my server it doesnt work. It consists of two pages. the upload page and an include. here is the upload form <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <body> <?php include('http://www.myserver.com/vhtest/includes/test4.php'); ?> <form action="" method="post" enctype="multipart/form-data" name="form1" id="form1"> <input name="image" type="file" id="image" /> <input type="submit" name="Submit" value="Submit" /> </form> </body> </html> here is the include <?php if($_POST){ $img = $_FILES['image']['tmp_name']; //$percent = $_GET['percent']; $constrain = 1; $w = 500; $h = 380; // get image size of img $x = @getimagesize($img); // image width $sw = $x[0]; // image height $sh = $x[1]; if ($percent > 0) { // calculate resized height and width if percent is defined $percent = $percent * 0.01; $w = $sw * $percent; $h = $sh * $percent; } else { if (isset ($w) AND !isset ($h)) { // autocompute height if only width is set $h = (100 / ($sw / $w)) * .01; $h = @round ($sh * $h); } elseif (isset ($h) AND !isset ($w)) { // autocompute width if only height is set $w = (100 / ($sh / $h)) * .01; $w = @round ($sw * $w); } elseif (isset ($h) AND isset ($w) AND isset ($constrain)) { // get the smaller resulting image dimension if both height // and width are set and $constrain is also set $hx = (100 / ($sw / $w)) * .01; $hx = @round ($sh * $hx); $wx = (100 / ($sh / $h)) * .01; $wx = @round ($sw * $wx); if ($hx < $h) { $h = (100 / ($sw / $w)) * .01; $h = @round ($sh * $h); } else { $w = (100 / ($sh / $h)) * .01; $w = @round ($sw * $w); } } } $im = @ImageCreateFromJPEG ($img) or // Read JPEG Image $im = @ImageCreateFromPNG ($img) or // or PNG Image $im = @ImageCreateFromGIF ($img) or // or GIF Image $im = false; // If image is not JPEG, PNG, or GIF if (!$im) { // We get errors from PHP's ImageCreate functions... // So let's echo back the contents of the actual image. readfile ($img); } else { // Create the resized image destination $thumb = @ImageCreateTrueColor ($w, $h); // Copy from image source, resize it, and paste to image destination @ImageCopyResampled ($thumb, $im, 0, 0, 0, 0, $w, $h, $sw, $sh); // Output resized image $filename = "../vhtest/upload/jim/2/". $_FILES['image']['name']; imagejpeg($thumb,$filename,100); } } ?> my local machine has php 5. my server has php 4.4 first question is there something in the include that doesnt work for php4.4? I looked up almost every function and they were all supported. And by the way the folder that I am trying to write to are all chmod 777. the second question is does it need a absolute path or can it use a relative path? on my local machine it works with a relative path. I have tried changing the path to include 1 a relative path ie "../vhtest/upload/jim/2/". $_FILES['image']['name']; 2 the full path to the folder ie /home/usr/vhtest/upload/ etc 3 an http path ie htttp://www.myserver.com.vhtest/upload etc none of them seem to work. I had this in a much more complicated page where I have multiple upload and mysql insert. I thought there might be someproblem in there so I built this simple form to test it out. Once again everything works on my local machine but not on the server. Any help would be greatly appreciated. thanks Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.