使用Uploadify上传时如何在每张图片上创建水印?

时间:2012-02-02 10:00:43

标签: php jquery uploadify

我想用自己的文字创建一个水印。我想在每张图片上创建“ABDULLAH”的水印。我在uploadify.php文件中有这些代码行。

<?php
if (!empty($_FILES)) {
    $tempFile = $_FILES['Filedata']['tmp_name'];
    $targetPath = $_SERVER['DOCUMENT_ROOT'] . $_REQUEST['folder'] . '/'; 
    $ext = end(explode(".", $_FILES['Filedata']['name']));
    $FileName = current(explode('.', $_FILES['Filedata']['name']));
    $originalFileName = $FileName.".".$ext;
    $strRandNum = rand(0,99)+strtotime(date('YmdHis'));
    $randomeFileName = $FileName."_".$strRandNum."_uid_".$_REQUEST['user_id'];
    $completeFileName = $randomeFileName.".".$ext;
    $dir_path =  $_SERVER['DOCUMENT_ROOT'] . $_REQUEST['folder'] .'/'. $dirctory_name. "/";
    if( (isset ($dirctory_name)) && ($dirctory_name != "") && (is_dir ($dir_path)) ) {
        move_uploaded_file($tempFile,$dir_path.$completeFileName);
    }
    else {
        mkdir($dir_path , 0777);
        move_uploaded_file($tempFile,$dir_path.$completeFileName);
    }
    str_replace($_SERVER['DOCUMENT_ROOT'],'',$targetFile);
}
?>

2 个答案:

答案 0 :(得分:1)

  

好吧,你不能用javascript“uploadify”阿卜杜拉先生

做到这一点      

你必须使用php gd lib才能输出水印

已完成 AFTER 上传图像

检查出来

http://www.sitepoint.com/watermark-images-php/

答案 1 :(得分:0)

您可能需要某种形式的服务器端功能。

CodeIgniter提供了一种在文件上传过程中为图像添加水印的内置且简单的方法。查看他们的uploading filesimage manipulation文档。