发一个上传图片并返回地址到剪贴板的PHP代码

<?php
if($_POST['upload']=='OK'){
$uploaddir = './attachment/';
$fil_extend_ename = end(explode('.',basename($_FILES['userfile']['name'])));
$uploadfile = $uploaddir . date("YmdHis", time()) . floor(microtime()*1000).'.'.$fil_extend_ename;
echo '<pre>';
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
echo "<script type='text/javascript' >alert('上传成功!'); window.location.href='upload.php?id=$uploadfile';</script>";
} else {
echo "<script type='text/javascript'>alert('上传失败!');location.href='upload.php';</script>";
}
echo '下面是一些调试信息:';
print_r($_FILES);
print "</pre>";
}
?>

<div style="position: relative; top: 100px; text-align:center;" />
<form action="#" style="margin-left: 45px;" method="POST" enctype="multipart/form-data" />
<input type="hidden" name="MAX_FILE_SIZE" value="2097152" />
开始上传: 
<input type= "file" name="userfile" id="uploadfile" style="display: none" />
<input type= "file" name="userfile" value="<?php echo($_REQUEST['id'])?>" />
<input type="hidden" name="upload" value="OK" />
<input type="submit" value="上传" />
<script> function oCopy(obj){ obj.select(); js=obj.createTextRange(); js.execCommand("Copy") } </script>
<br><br>
相对地址:
<input type="text" style="width:400; height:25" value="<?php echo($_REQUEST['id'])?>" onclick="oCopy(this)" />
<br><br>
<input type="button" style="width:100; height:25" value="返回首页" onClick="location.href='http://iklfy.com';" />
</div>

评论列表

南宁广告公司
先copy下来再说
2012-10-30 11:38:52