Heim > Fragen und Antworten > Hauptteil
<?php
$target=imagecreatefrompng($_FILES['test']['tmp_name']);
header("Content-type: image/png;");
imagepng($target);
imagedestroy($target);
Win64-apache2.4.9-php5.5.12
Ubuntu64-apache2.4.7-php5.5.9
GD库已经开启(成功处理验证码并输出)
文件夹权限正常(读写文件成功)
<?php
前没有内容
直接输出上传的文件,失败
<?php
$target=imagecreatefrompng($_FILES['test']['tmp_name']);
header("Content-type: image/png;");
imagepng($target);
imagedestroy($target);
读取服务端文件并输出,成功
<?php
$target=imagecreatefrompng('./interface/render_pic_v1/templates/bitcard/front.png');
header("Content-type: image/png;");
imagepng($target);
imagedestroy($target);
重命名上传的文件并输出,失败
<?php
$target_path=$_FILES['test']['tmp_name'].'.png';
move_uploaded_file($_FILES['test']['tmp_name'],$target_path);
$target=imagecreatefrompng($target_path);
header("Content-type: image/png;");
imagepng($target);
imagedestroy($target);
读取上次会话上传的文件并输出,成功
<?php
// $target_path=$_FILES['test']['tmp_name'].'.png';
$target_path="C:\\Program Files (x42)\\WampServer\\tmp\\phpB808.tmp.png";
// move_uploaded_file($_FILES['test']['tmp_name'],$target_path);
$target=imagecreatefrompng($target_path);
header("Content-type: image/png;");
imagepng($target);
imagedestroy($target);
成功截图:
-失败截图:
<?php
// header("Content-type: text/html; charset=utf-8");
// $x=$interface_path.'/templates/bitcard/front.png';
// $interface_path='./interface/render_pic_v1';
// $x='./interface/render_pic_v1/templates/bitcard/front.png';
// $target=imagecreatefrompng($x);
// require $interface_path.'/functions_lib/image_process.php';
// copy($_FILES['test']['tmp_name'],'./interface/render_pic_v1/result/test.png');
// rename($_FILES['test']['tmp_name'],$_FILES['test']['tmp_name'].'.png');
// $target_path='./interface/render_pic_v1/result/'.md5_file($_FILES['test']['tmp_name']).'-'.time().'-'.$_FILES['test']['name'];
// move_uploaded_file($_FILES['test']['tmp_name'],$target_path);
// $target=imagecreatefrompng($target_path);
// $target=imagecreatefrompng($_FILES['test']['tmp_name'].'.png');
// $target=imagecreatefrompng($_FILES['test']['tmp_name']);
// if($target=fopen($_FILES['test']['tmp_name'])){echo "string2";}
// $source=imagecreatefrompng('C:\\Program Files (x42)\\WampServer\\tmp\\phpE925.tmp.png');
// $source=imagecreatefrompng('/var/www/html/bit_if/temp/phpniambi.png');
// $target=imagecreatefrompng('./interface/render_pic_v1/result/test.png');
// $target=imagecreatefrompng('./interface/render_pic_v1/result/test');
// var_dump($_FILES['test']['tmp_name']);
// var_dump($_FILES['test']['tmp_name'].'.png');
// $position_target=array('x'=>330,'y'=>339);
// $position_source=array('x'=>0,'y'=>0,'w'=>288,'h'=>402);
// setPicture($target, $source, $position_target, $position_source);
// header("Content-type: image/png; charset=utf-8");
// header("Content-type: image/png;");
// imagepng($target);
// imagedestroy($target);
// $target=imagecreatefrompng($_FILES['test']['tmp_name']);
// var_dump($_FILES);