如何使用PHP

时间:2017-12-13 05:17:45

标签: php watermark

这里我正在进行多个图像上传,用户选择图像并单击提交按钮意味着我想在该图像中添加水印之后我必须在临时文件夹中移动图像,除了在我已经完成的图像中添加水,我不知道如何在图像中添加水印,如果有人知道意味着请更新我的答案

 $("#rentBtnSubmit").click(function(e){
	e.preventDefault();
	 var formData = new FormData();
			var formData = new FormData($('#rentForm')[0]);
			formData.append('file[]', $('input[type=file]')[0].files[0]);
			$.ajax({
			 type:'POST',
			  url :"test.php",
			  data: formData,
				cache: false,
				contentType: false,
				processData: false,
				success: function(data) {
					if(data['status'] =='success'){
					  alert('Success');
                     }
                     else{
						 alert('Error');
                     } 
				   },
			 error:function(exception){
			 $("#rentError").show(); 
			$("#rentError").fadeOut(4000); 
			}
			}); 
			});
<form id="rentForm">
<div class="row">
        <div class="col-md-12">
			<div class="form-group">
			<label class="control-label">Upload Property Photo</label>
			<br>
			<div id="maindiv">
			<div id="formdiv">
			<span id="filediv col-md-3"><input name="file[]" type="file" id="file" multiple=""/></span>
		  </div>
		</div>
		</div>		
	</div>
</div><br><br>
<button type="button center-block"  id="rentBtnSubmit">Submit</button>
</form>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>

  

test.php的

    $FilleAll = $_FILES['file']['name'];
    $fileCount = count($FilleAll);
    for ($i = 1; $i < count($FilleAll); $i++) {
    $extension = pathinfo( basename($_FILES['file']['name'][$i]), PATHINFO_EXTENSION);
    $image_filename= md5(basename($_FILES['file']['name'][$i]).time()).'.'.$extension;
    $move = move_uploaded_file($_FILES['file']['tmp_name'][$i],"watermark_images/".$image_filename);
}

0 个答案:

没有答案