anthonydamasco Posted March 1, 2007 Share Posted March 1, 2007 I have a script that I've been messing with and I am having trouble setting a path for images, I'm getting an upload failed response on the webserver the path is www/OEM/admin/thumbs the php page is located in the "admin" folder Ive tried both paths, I think I'm messing something up. <form action="add.php" method="post" enctype="multipart/form-data" name="form1"> <input type="file" name="userfile"> </form> <?php $path = "/thumbs/"; $max_size = 2000000; if (!isset($HTTP_POST_FILES['userfile'])) exit; if (is_uploaded_file($HTTP_POST_FILES['userfile']['tmp_name'])) { if ($HTTP_POST_FILES['userfile']['size']>$max_size) { echo "The file is too big<br>n"; exit; } if (($HTTP_POST_FILES['userfile']['type']=="image/gif") || ($HTTP_POST_FILES['userfile']['type']=="image/pjpeg") || ($HTTP_POST_FILES['userfile']['type']=="image/jpeg") || ($HTTP_POST_FILES['userfile']['type']=="image/png")) { if (file_exists($path . $HTTP_POST_FILES['userfile']['name'])) { echo "The file already exists<br>n"; exit; } $res = copy($HTTP_POST_FILES['userfile']['tmp_name'], $path . $HTTP_POST_FILES['userfile']['name']); if (!$res) { echo "upload failed!<br>n"; exit; } else { echo "upload sucessful<br>n"; } echo "File Name: ".$HTTP_POST_FILES['userfile']['name']."<br>n"; echo "File Size: ".$HTTP_POST_FILES['userfile']['size']." bytes<br>n"; echo "File Type: ".$HTTP_POST_FILES['userfile']['type']."<br>n"; } else { echo "Wrong file type<br>n"; exit; } } $my_file = $HTTP_POST_FILES['userfile']['name']; ?> ERROR "upload failed!" Any one have ideas? Quote Link to comment https://forums.phpfreaks.com/topic/40769-image-upload-failure/ Share on other sites More sharing options...
magnetica Posted March 1, 2007 Share Posted March 1, 2007 What browser are you using because IE and FF have trouble uploading jpeg images Quote Link to comment https://forums.phpfreaks.com/topic/40769-image-upload-failure/#findComment-197359 Share on other sites More sharing options...
anthonydamasco Posted March 1, 2007 Author Share Posted March 1, 2007 gifs, BMPS, and PNGs dont work either for me, so I think its more than a browser thing I cant figure it out >< Quote Link to comment https://forums.phpfreaks.com/topic/40769-image-upload-failure/#findComment-197364 Share on other sites More sharing options...
MadTechie Posted March 1, 2007 Share Posted March 1, 2007 i use Absolute paths also check to the access rights to that folder, must be writable Quote Link to comment https://forums.phpfreaks.com/topic/40769-image-upload-failure/#findComment-197365 Share on other sites More sharing options...
anthonydamasco Posted March 1, 2007 Author Share Posted March 1, 2007 Now im using absolute paths and I'm still having a problem Quote Link to comment https://forums.phpfreaks.com/topic/40769-image-upload-failure/#findComment-197382 Share on other sites More sharing options...
bwochinski Posted March 1, 2007 Share Posted March 1, 2007 The $root_path variable is the code I use to set up absolute paths for image uploads: $root_path = $_SERVER['DOCUMENT_ROOT'].str_replace(basename($_SERVER['PHP_SELF']),'',$_SERVER['PHP_SELF']); $path = $root_path."thumbs/"; Quote Link to comment https://forums.phpfreaks.com/topic/40769-image-upload-failure/#findComment-197387 Share on other sites More sharing options...
MadTechie Posted March 1, 2007 Share Posted March 1, 2007 try uploading a file (test1.txt) to the absolute path of "/thumbs/" and try the code below. <?php $path = "/thumbs/"; #<-- change to absolute path $avar1 = "test1.txt"; $avar2 = "test2.txt"; echo copy($path.$avar1, $path.$avar2); ?> .. nice snippet bwochinski Quote Link to comment https://forums.phpfreaks.com/topic/40769-image-upload-failure/#findComment-197388 Share on other sites More sharing options...
anthonydamasco Posted March 1, 2007 Author Share Posted March 1, 2007 <?php $path = "/usr/home/travis/www/OEM/admin/thumbs/"; $avar1 = "test1.txt"; $avar2 = "test2.txt"; echo copy($path.$avar1, $path.$avar2); ?> I get a blank white page.. lol I dont think it works Quote Link to comment https://forums.phpfreaks.com/topic/40769-image-upload-failure/#findComment-197390 Share on other sites More sharing options...
MadTechie Posted March 1, 2007 Share Posted March 1, 2007 copy failed.. check folder rights whats the access rights of the folder thumbs ? did test1.txt upload ok ? Quote Link to comment https://forums.phpfreaks.com/topic/40769-image-upload-failure/#findComment-197391 Share on other sites More sharing options...
itsmeArry Posted March 2, 2007 Share Posted March 2, 2007 dorry I didn't read it ignore this reply..... here is the problem you missed a "/" $avar1 = "/test1.txt"; $avar2 = "/test2.txt"; echo copy($path.$avar1, $path.$avar2); this will work if you have permissions on the folder thumbs Quote Link to comment https://forums.phpfreaks.com/topic/40769-image-upload-failure/#findComment-197708 Share on other sites More sharing options...
MadTechie Posted March 3, 2007 Share Posted March 3, 2007 anthonydamasco, hows the code going ? resolved yet? Quote Link to comment https://forums.phpfreaks.com/topic/40769-image-upload-failure/#findComment-198492 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.