1. 调用方法例子:
大图路径:<input type="text" name="bigImageURL" id="bigImageURL" value="">
<iframe src="uppic.php?id=bigImageURL" width="600" height="25" frameborder="0" scrolling="no"></iframe>
小图路径:
<input type="text" name="smallImageURL" id="smallImageURL" value="">
<iframe src="uppic.php?id=smallImageURL" width="600" height="25" frameborder="0" scrolling="no"></iframe>
2. uppic.php
<?php
header("Content-Type:text/html;charset=GB2312");
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<HTML xmlns="http://www.w3.org/1999/xhtml">
<HEAD>
<TITLE>图片上传</TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<META content="MSHTML 6.00.3790.4275" name=GENERATOR>
<style type="text/css">
<!--
input{border-width:1px;border:1px solid #bdbcbd;padding:3px 0 3px 5px;}
.inputbut{padding-left:3px;padding-right:2px;border:1px solid #bdbcbd;background:#FFF url(../images/inputbut_bg.gif) left center repeat-x;font-size:12px;height:24px;}
-->
</style>
</HEAD>
<BODY leftmargin=0 topmargin=0 style="font-size:12px">
<?php
$id=$_GET["id"];
//echo "id==".$id;
switch($_GET["action"])
{
case "up":
upmovie($id);
break;
default:
upinput($id);
break;
}
function upinput($id){
?>
<SCRIPT language=javascript>
function check()
{
var strFileName=document.form.strPhoto.value;
if (strFileName=="")
{
alert("请选择要上传的文件");
document.form.strPhoto.focus();
return false;
}
return true;
}
</SCRIPT>
<form action="uppic.php?action=up&id=<?=$id?>" enctype="multipart/form-data" name="form" method="post" onsubmit="if (!check()) return false;">
<input name="strPhoto" type="file" id="strPhoto" size="40">
<input type="submit" name="Submit" value="上 传" class=inputbut />
</form>
</BODY>
<?php
}
function upmovie($id){
global $web_picdir;
$savePath=dirname(__FILE__)."/".$web_picdir;
$str = date('YmdHis');
if($_FILES['strPhoto']['name']!='')
{
$tmp_file=$_FILES['strPhoto']['tmp_name'];
$file_types=explode(".",$_FILES['strPhoto']['name']);
$file_type=$file_types[count($file_types)-1];
if(strtolower($file_type)!="jpg"&strtolower($file_type)!="gif"&strtolower($file_type)!="bmp"&strtolower($file_type)!="png"){
echo "<span style=/"color:red;line-height: 25px;/">格式错误请重新上传<a href=# onclick=history.go(-1);>[返回]</a></span>";
exit;
}
$file_name=$str.".".$file_type;
if(!copy($tmp_file,$savePath.$file_name)){
echo "<span style=/"color:red;line-height: 25px;/">上传错误请重试!!<a href=# onclick=history.go(-1);>[返回]</a></span>";
}else{
//echo "<span style=/"olor:red;line-height: 25px;/">上传成功</span><script>parent.document.getElementById(/"bigImageURL/").value=/"".$file_name."/"</script>";
echo "<span style=/"olor:red;line-height: 25px;/">上传成功</span><script>parent.document.getElementById(/"{$id}/").value=/"".$file_name."/"</script>";
echo "<a href=# onclick=history.go(-1);>,若需要修改,请重新上传</a>";
}
}else{
echo "<span style=/"color:red;line-height: 25px;/">请选择需要上传的文件<a href=# onclick=history.go(-1);>[返回]</a></span>";
}
}
?>
注意: 不同的文本框 需要定义id, iframe url: uppic.php?id=文本框id
分享到:
相关推荐
本文实例讲述了php上传图片获取路径及给表单字段赋值的方法。分享给大家供大家参考,具体如下: 1. 调用方法例子: 大图路径: <input type="text" name="bigImageURL" id="bigImageURL" value=""> <...
A_jquery+select框图片选择器点击图片给表单select框赋值Java实用源码整理learns
php模拟表单上传图片 POST ,做一个b.php,接收数据
java 基础表单验证方法,java 基础表单验证方法,java 基础表单验证方法
怎么用jquery实现,文本框获得焦点之后弹出一个层,层里面的内容最好是动态获取的。点击层里面的内容后为input赋值
A_jquery+select框图片选择器点击图片给表单select框赋值分享源码学习a(密码:http://hao.360.cn/?src=lm&ls=n527fd66b97)
界面相当美观,做UI设计值得推荐和参考,无论是电子商务平台,或者是物联网系统均可以作为参考设计
<h2>jQuery 表单元素取值与赋值方法总结 <input type="text" class="test1"/> <input type="button" value="赋值" onclick="get()"/> <input type="text" class="test2"/> [removed] ...
很多时候一个表单太多的字段,如何能够高效获取表单字段,也为如何提神开发的效率和统一性? 比如一个系统的某个有26个字段,那么我用表单的名称用26个a到z的字母, 你是选择 <input type=”text” name=”a”>...
php sqlbuddy133 for sqlite3 在线管理 支持表单增加字段
——学习参考资料:仅用于个人学习使用! javascript代码-使用代码解决Jquery给easyui的表单元素赋值,获取值总结的源代码
如下所示: form表单ID:postform 设置表单请求url document.postform.action = SaveReturnInfo...以上就是小编为大家带来的js 提交form表单和设置form表单请求路径的实现方法全部内容了,希望大家多多支持软件开发网~
OA二次开发 js
2、自定义表单模型(自定义字段支持字符串、数字、单选、多选、下拉、日历、时间、邮件、省市区、上传图片),每个自定义字段支持自定义描述(字段提示),支持关联会员表字段并支持会员表自定义字段;3、多个表单提交页...
把该文件放在d盘根目录下,运行此文件可以自动提取表单字段,并创建表
libcurl 提交post表单数据 上传图片 demo 根据网页请求协议,模拟post表单的方式上传数据,并最返回数据进行处理
php curl模仿form表单提交图片或文件 用的tp5做的例子
Servlet中对获取网页表单数据自动给JavaBean赋值的BeanUtil工具类 Servlet中对获取网页表单数据自动给JavaBean赋值的BeanUtil工具类
1、使用Vue.js实现双向表单数据绑定,例子 <!--html代码--> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <...