复制代码
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <?php
- /*
- * Created on 2010-3-30
- *
- * To change the template for this generated file go to
- * Window - Preferences - PHPeclipse - PHP - Code Templates
- * 文件上传
- */
- if(isset($_POST['submit'])) {
- $upfile=@$_FILES["upfile"];
- $name=$upfile["name"];
- $uptype=pathinfo($name,PATHINFO_EXTENSION);//上传文件类型
- //echo $uptype;
- $name=mktime().".".$uptype;
- $type=$upfile["type"];
- $tmp_name=$upfile["tmp_name"];
- $error=$upfile["error"];
- $size=$upfile["size"];
- $path="../upload/";
- switch($type) {
- case "application/octet-stream":
- $ok=1;
- break;
- case "application/pdf":
- $ok=1;
- break;
- case "application/msword":
- $ok=1;
- break;
- }
- if(@!$ok) {
- $tishi= "你上传的文件类型非法";
- }else {
- if(is_uploaded_file($upfile["tmp_name"])) {
- move_uploaded_file($tmp_name,$path.$name);
- $tishi= "上传成功";
- }
- }
- }
- ?>
- <script type="text/javascript">
- parent.form_fox.file.value = "<?php echo $path.$name;?>";//这个把路径传给父窗口的一个文本框里
- </script>
- <form action="" method="post" enctype="multipart/form-data">
- <input type="file" name="upfile"/>
- <input type="submit"name="submit" value="上传"/> <?php echo $tishi;?>
-
- </form>
|
这个是upfile.php上传文件的.
复制代码
- <form name="form_fox" onSubmit="return checkinput()" method="post" action="newsadd.php">
- <tr>
- <td colspan="2" class="red">发布资料,技术文档,产品说明!!!</td>
- </tr>
- <tr>
- <td width="80" align="center"><span class="left_txt2">资料标题:</span></td>
- <td><input id="topic6" size="31" name="title" class="button01" />
- <span class="red">*</span></td>
- </tr>
- <tr>
- <td align="center"><span class="left_txt2">资料类别:</span></td>
- <td><span class="left_txt">
- <select name="c_id" id="c_id">
- <?php
- $query=$link->read_mysql("p_newsclass","where f_id=0 and lang='ch'");
- while($row=mysql_fetch_array($query)) {
- $dalei[$row["id"]]=$row["name"];
- echo "<option value='".$row['id'].",".$row['f_id']."'>".$row['name']."</option>";
- $id=$row['id'];
- $query2=$link->read_mysql("p_newsclass","where f_id=$id");
- while($row=mysql_fetch_array($query2)) {
- echo "<option value='".$row['id'].",".$row['f_id']."'>┠".$row['name']."</option>";
- }
- }
- ?>
- </select>
- <span class="red">*</span></span></td>
- </tr>
- <tr>
- <td align="center"><span class="left_txt2">文件上传:</span></td>
- <td>
- <iframe src="../common/upfile.php" name="ww" width="500" height="35" scrolling="No" frameborder="0" id="ww"></iframe>
- <input type="text" name="file" id="file"/>//接收路径
- </td>
- </tr>
- <tr>
- <td align="center"> </td>
- <td><input class="submit_button" border="0" name="I5" type="submit" value="确认发布" />
- <input size="15" name="key" class="button01" value="add" type="hidden" /></td>
- </tr>
- </form>
|
现在就是这个,在父窗口中接收不到路径,报错
'700')this.width='700';if(this.offsetHeight>'700')this.height='700';" title="Click Here To EnLarge">