Jump to content

PhpSyntaxerror

Members
  • Posts

    6
  • Joined

  • Last visited

PhpSyntaxerror's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. im not understanding how to put if (!is_uploaded_file($_FILES[$this->fileName]['tmp_name'])) { $this->msg .= 'File did not reach temporary location on the server<br />'; return false; } $fleName = $_FILES[$this->fileName]['name']; $flePath = $this->folderPath ? $this->folderPath . '/' . $fleName : $fleName; // test if a file with the same name exist, and rename if it does if (file_exists($flePath)) { as to $fileName = $_FILES[$this->fileName]['name']; $watermark = imagecreatefrompng('optimized\images\watermark.png'); $waterInfo = getimagesize('optimized\images\watermark.png'); $x = $filename[0] - $waterInfo[0] - 5; $y = $filename[1] - $waterInfo[1] - 5; //add the watermark to the image imagecopy($filename, $watermark, $x, $y, 0, 0, $waterInfo[0], $waterInfo[1]); //display it onscreen header('Content-Type: image/jpeg'); imagejpeg($filename); im not sure something like that but when i do i just get a blank page
  2. i did already complain to the head of department funny thing is she kept supporting him because she was the one who hired him. ive been on trying to do water mark for almost 30hrs now and its here almost 3am almost im not trying to ask anyone to do it for me im at a point where i am stuck.
  3. its the best of what i can with the circumstances
  4. ive tried a few times but the quality of the teacher that thought me was very low it was his first class and he didnt make any sense and was sometimes teaching us backwards his grammar was horrible i did not understand anything or retrain anything he had said so i learn php my self slowly
  5. hi ive tried a couple of them but i will load up some of the ones ive save as in water marking but i seems i not too sure how to intergrate a interchangeable one from the form to the ones that people had made online >< im not sure how to fit the together into my upload class that does the watermarking. <?php //open up the images $fleName = $_FILES[$this->fileName]['name']; //get the image information $dolpInfo = getimagesize('dolphin.jpg'); $watermark = imagecreatefrompng('optimized\images\watermark.png'); $waterInfo = getimagesize('optimized\images\watermark.png'); $x = $dolpInfo[0] - $waterInfo[0] - 5; $y = $dolpInfo[1] - $waterInfo[1] - 5; //add the watermark to the image imagecopy($dolphin, $watermark, $x, $y, 0, 0, $waterInfo[0], $waterInfo[1]); //display it onscreen header('Content-Type: image/jpeg'); imagejpeg($dolphin); ?> also tried intergrating <?php // Load the stamp and the photo to apply the watermark to $im = imagecreatefromjpeg('photo.jpeg'); // First we create our stamp image manually from GD $stamp = imagecreatetruecolor(100, 70); imagefilledrectangle($stamp, 0, 0, 99, 69, 0x0000FF); imagefilledrectangle($stamp, 9, 9, 90, 60, 0xFFFFFF); $im = imagecreatefromjpeg('photo.jpeg'); imagestring($stamp, 5, 20, 20, 'libGD', 0x0000FF); imagestring($stamp, 3, 20, 40, '© 2007-9', 0x0000FF); // Set the margins for the stamp and get the height/width of the stamp image $marge_right = 10; $marge_bottom = 10; $sx = imagesx($stamp); $sy = imagesy($stamp); // Merge the stamp onto our photo with an opacity of 50% imagecopymerge($im, $stamp, imagesx($im) - $sx - $marge_right, imagesy($im) - $sy - $marge_bottom, 0, 0, imagesx($stamp), imagesy($stamp), 50); // Save the image to file and free memory imagepng($im, 'photo_stamp.png'); imagedestroy($im); ?> and <?php function watermarkImage ($SourceFile, $WaterMarkText, $DestinationFile) { list($width, $height) = getimagesize($SourceFile); $image_p = imagecreatetruecolor($width, $height); $image = imagecreatefromjpeg($SourceFile); imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width, $height); $black = imagecolorallocate($image_p, 0, 0, 0); $font = 'arial.ttf'; $font_size = 10; imagettftext($image_p, $font_size, 0, 10, 20, $black, $font, $WaterMarkText); if ($DestinationFile<>'') { imagejpeg ($image_p, $DestinationFile, 100); } else { header('Content-Type: image/jpeg'); imagejpeg($image_p, null, 100); }; imagedestroy($image); imagedestroy($image_p); }; ?>
  6. Hi guys ive been stuck all day since yesterday ive been trying figure out how to integrate water marking to existing upload class ive had no luck yet ive proberly tried about 30 water marking trying to integrate them but all failed could anyone show me a way to intergrate water marking with this upload, im fairly new to php is still learning sorry if im seen noobish <?php /* ** This class contains the method to upload a file */ class Upload { private $fileName; // name of the file from the upload form private $fileTypes = array(); // array of valid file types for upload private $folderPath; // folder where uploaded files will be moved public $msg; // messages generated from this class public function __construct($fileName, $fileTypes, $folderPath) { $this->fileName = $fileName; $this->fileTypes = $fileTypes; $this->folderPath = $folderPath; } public function isUploaded() // this function will contain the statements to process file upload // and returns the name of the file upon successful upload // or returns false otherwise. It also sets the upload message ($this->msg) { $this->msg = ''; // check if the name of the file uploaded is not available if (!$_FILES[$this->fileName]['name']) { $this->msg .= 'File name not available'; return false; } // test for error in uploading if ($_FILES[$this->fileName]['error']) { switch ($_FILES[$this->fileName]['error']) { case 1: $this->msg .= 'File exceeds PHP\'s maximum upload size<br />'; return false; case 2: $this->msg .= 'File exceeds maximum upload file set in the form<br />'; return false; case 3: $this->msg .= 'File partially uploaded<br />'; return false; case 4: $this->msg .= 'No file uploaded<br />'; return false; } } // check if file type is invalid $type = $_FILES[$this->fileName]['type']; // get the type of the uploaded file if (!in_array($type, $this->fileTypes)) { $this->msg .= 'Wrong file type<br />'; return false; } // check if file did not reach the server (temp location) if (!is_uploaded_file($_FILES[$this->fileName]['tmp_name'])) { $this->msg .= 'File did not reach temporary location on the server<br />'; return false; } $fleName = $_FILES[$this->fileName]['name']; $flePath = $this->folderPath ? $this->folderPath . '/' . $fleName : $fleName; // test if a file with the same name exist, and rename if it does if (file_exists($flePath)) { $newName = uniqid('LD') . $fleName; $this->msg .= 'File ' . $fleName . ' already exists, renamed to ' . $newName . '<br />'; $flePath = $this->folderPath ? $this->folderPath . '/' . $newName : $newName; } // move file from temporary location to the path specified // and test if it's not successful if (!move_uploaded_file($_FILES[$this->fileName]['tmp_name'], $flePath)) { $this->msg .= 'Error in moving file to specified location<br />'; return false; } // check if file does not exist on the destination folder if (!file_exists($flePath)) { $this->msg .= 'File did not reach destination folder<br />'; return false; } $this->msg .= 'File ' . $_FILES[$this->fileName]['name'] . ' uploaded successfully<br />'; return $flePath; } } ?>
×
×
  • 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.