Jump to content

maxso

Members
  • Posts

    55
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

maxso's Achievements

Member

Member (2/5)

0

Reputation

  1. Thank you all who helped. Thank you to Work_it_work who solved it also. $result = @move_uploaded_file($_FILES['image_file']['tmp_name'], $newimage); if(!empty($result)) { $error["result"] = "There was an error moving the uploaded file." ;} else { echo "complete"; } Topic solved
  2. It checks if they have left that box empty or not. if(result) doesnt meen anything does it? If result=what?
  3. After i upload a file, it just shows the same with no changes.
  4. In my script it has a semi-colon
  5. I tried an else statement like... $result = @move_uploaded_file($_FILES['image_file']['tmp_name'], $newimage); if(empty($result)) $error["result"] = "There was an error moving the uploaded file."; else{ echo "complete" } but it didnt say anything after the upload so i dont know.
  6. What if statement can determine whether an upload was complete from this piece of code? <? //print_r($_POST); if($_POST["action"] == "Upload Image") { unset($imagename); if(!isset($_FILES) && isset($HTTP_POST_FILES)) $_FILES = $HTTP_POST_FILES; if(!isset($_FILES['image_file'])) $error["image_file"] = "An image was not found."; $imagename = basename($_FILES['image_file']['name']); //echo $imagename; if(empty($imagename)) $error["imagename"] = "The name of the image was not found."; if(empty($error)) { $newimage = "images/" . $imagename; //echo $newimage; $result = @move_uploaded_file($_FILES['image_file']['tmp_name'], $newimage); if(empty($result)) $error["result"] = "There was an error moving the uploaded file."; } } include("upload_form.php"); if(is_array($error)) { while(list($key, $val) = each($error)) { echo $val; echo "<br>\n"; } } ?>
  7. This is an existing code from a tutorial I have used. I have been looking at watermarking gd() tutorials but it hasn't helped me very much.
  8. Ok so I want to watermark the images people upload. Here is my script so far. upload.php <? //print_r($_POST); if($_POST["action"] == "Upload Image") { unset($imagename); if(!isset($_FILES) && isset($HTTP_POST_FILES)) $_FILES = $HTTP_POST_FILES; if(!isset($_FILES['image_file'])) $error["image_file"] = "An image was not found."; $imagename = basename($_FILES['image_file']['name']); //echo $imagename; if(empty($imagename)) $error["imagename"] = "The name of the image was not found."; if(empty($error)) { $newimage = "images/" . $imagename; //echo $newimage; $result = @move_uploaded_file($_FILES['image_file']['tmp_name'], $newimage); if(empty($result)) $error["result"] = "There was an error moving the uploaded file."; } } include("upload_form.php"); if(is_array($error)) { while(list($key, $val) = each($error)) { echo $val; echo "<br>\n"; } } ?> upload_form.php <form method="POST" enctype="multipart/form-data" name="image_upload_form" action="<?$_SERVER["PHP_SELF"];?>"> <p><input type="file" name="image_file" size="20"></p> <p><input type="submit" value="Upload Image" name="action"></p> </form> Where and how could I place my code so that it places a watermark upon upload.
  9. I think I have messed it up lol. All i wanted was for when someone uploaded a file, it would instantly put a watermark onto the file.
  10. now it says The line is $watermarkfile = '/8.png'
  11. <?php function watermark($sourcefile, $watermarkfile, $saveFile) { # $sourcefile = '/background.jpg' $watermarkfile = '/8.png' $saveFile = '/new.png' # //Get the resource ids of the pictures $watermarkfile_id = imagecreatefrompng($watermarkfile); imageAlphaBlending($watermarkfile_id, false); imageSaveAlpha($watermarkfile_id, true); $fileType = strtolower(substr($sourcefile, strlen($sourcefile)-3)); switch($fileType) { case('gif'): $sourcefile_id = imagecreatefromgif($sourcefile); break; case('png'): $sourcefile_id = imagecreatefrompng($sourcefile); break; default: $sourcefile_id = imagecreatefromjpeg($sourcefile); } //Get the sizes of both pix $sourcefile_width=imageSX($sourcefile_id); $sourcefile_height=imageSY($sourcefile_id); $watermarkfile_width=imageSX($watermarkfile_id); $watermarkfile_height=imageSY($watermarkfile_id); if(isset($_REQUEST['imgPhoto_x'])) { $dest_x = $_REQUEST['imgPhoto_x']; $dest_y = $_REQUEST['imgPhoto_y']; } else { $dest_x = ( $sourcefile_width / 2 ) - ( $watermarkfile_width / 2 ); $dest_y = ( $sourcefile_height / 2 ) - ( $watermarkfile_height / 2 ); } // if a gif, we have to upsample it to a truecolor image if($fileType == 'gif') { // create an empty truecolor container $tempimage = imagecreatetruecolor($sourcefile_width,$sourcefile_height); // copy the 8-bit gif into the truecolor image imagecopy($tempimage, $sourcefile_id, 0, 0, 0, 0,$sourcefile_width, $sourcefile_height); // copy the source_id int $sourcefile_id = $tempimage; } imagecopy($sourcefile_id, $watermarkfile_id, $dest_x, $dest_y, 0, 0,$watermarkfile_width, $watermarkfile_height); //Create a jpeg out of the modified picture switch($fileType) { // remember we don't need gif any more, so we use only png or jpeg. // See the upsaple code immediately above to see how we handle gifs case('png'): //header("Content-type: image/png"); imagepng ($sourcefile_id); break; default: //header("Content-type: image/jpg"); if(imagejpeg ($sourcefile_id,$saveFile)) { } //echo "<img src='$saveFile'>"; } imagedestroy($sourcefile_id); imagedestroy($watermarkfile_id); return true; } ?> Thats my code so far but all i get is this.
  12. Ok, so i have a (sort of) upload site where people view other peoples pictures. My problem is that I want my logo to appear on the pictures and I don't want to do it manualy. Can anyone help me?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.