npsari Posted April 22, 2007 Share Posted April 22, 2007 I am using a simple upload file script <?php if ($File) { print("File name: $File_name<P>\n"); print ("File size: $File_size<P>\n"); if (Copy ($File, "/ads/images/$File_name")) { print("Your file was uploaded successfully<P>\n"); }else{ print("Your file could not be copied<P>\n"); } unlink ($File); } ?> But I get these messages... Warning: copy() [function.copy]: open_basedir restriction in effect. File(/ads/images/open.bmp) is not within the allowed path(s): (/home/npsari:/usr/lib/php:/usr/local/lib/php:/tmp) in /home/npsari/public_html/ads/insert/index.php on line 45 Warning: copy(/ads/images/open.bmp) [function.copy]: failed to open stream: Operation not permitted in /home/npsari/public_html/ads/insert/index.php on line 45 Your file could not be copied I even made the 'images' permission 777 anyone can spot a mistake ive done Link to comment https://forums.phpfreaks.com/topic/48123-image-upload-problems/ Share on other sites More sharing options...
clown[NOR] Posted April 22, 2007 Share Posted April 22, 2007 i dont think that's a valide way to upload... the way I'm doing it (because i dont know any other way is like this) <?php function uploadBilde($orgName,$newName) { unset($imagename); if(!isset($_FILES) && isset($HTTP_POST_FILES)) { $_FILES = $HTTP_POST_FILES; } if(!isset($_FILES['bilde'])) { $error["image_file"] = "An image was not found."; } $imagename = basename($_FILES['bilde']['name']); //echo $imagename; if(empty($imagename)) $error["imagename"] = "The name of the image was not found."; if(empty($error)) { $newimage = "images/members/" . $imagename; //echo $newimage; $result = move_uploaded_file($_FILES['bilde']['tmp_name'], $newimage); if(empty($result)) { $error["result"] = "There was an error moving the uploaded file."; } $newName = str_replace("@", "a", $newName); $newName = strtolower($newName); rename($newimage, "images/members/".$newName); chmod("images/members/".$newName, 0777); $image = "images/members/".$newName; $chkImageSize = getimagesize($image); $error = array(); if ($chkImageSize[0] > 300) { $error[] = "Bilde var for bredt. Max bredde = 300px"; } if ($chkImageSize[1] > 300) { $error[] = "Bilde var for høyt. Max høyde = 300px"; } if (!empty($error)) { foreach ($error as $err) { echo $err."<br>"; } } else { echo "Bildet ble lastet opp<br>"; } } } ?> PS: thisone also renames the images Link to comment https://forums.phpfreaks.com/topic/48123-image-upload-problems/#findComment-235183 Share on other sites More sharing options...
npsari Posted April 22, 2007 Author Share Posted April 22, 2007 Hey, thanks So what is the name of your "File upload" in the HTML form is it called blide? Link to comment https://forums.phpfreaks.com/topic/48123-image-upload-problems/#findComment-235186 Share on other sites More sharing options...
clown[NOR] Posted April 22, 2007 Share Posted April 22, 2007 yeah... that's image in my language =) Link to comment https://forums.phpfreaks.com/topic/48123-image-upload-problems/#findComment-235417 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.