Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/231.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 表格上载问题_Php_Html_Forms_Upload - Fatal编程技术网

Php 表格上载问题

Php 表格上载问题,php,html,forms,upload,Php,Html,Forms,Upload,我正在尝试实现这种方法来制作一个漂亮的表单上传: www.kavoir.com/2009/02/style-file-upload-select-input-control-input-typefile.html/ 这是惊人的和简单的,但我唯一的问题是,每次我选择一个文件,它显示为C:\fakepath\filename。我在mac电脑上,我一辈子都不知道这是从哪里来的!这是我的密码: <?php error_reporting(E_ALL ^ E_NOTICE); ini_set('di

我正在尝试实现这种方法来制作一个漂亮的表单上传:

www.kavoir.com/2009/02/style-file-upload-select-input-control-input-typefile.html/

这是惊人的和简单的,但我唯一的问题是,每次我选择一个文件,它显示为C:\fakepath\filename。我在mac电脑上,我一辈子都不知道这是从哪里来的!这是我的密码:

<?php
error_reporting(E_ALL ^ E_NOTICE);
ini_set('display_errors', '1');
if ($_POST['submit'] == "Submit") {
 $temp_file = $_FILES['upload']['tmp_name']."/".$_FILES['upload']['name'];
 $target_file = getcwd()."/uploads/".$_FILES['upload']['name'];
 // if (!move_uploaded_file($temp_file,$target_file)) {
 //  
 // }
}


?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>

 <title>untitled</title>
 <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
 <style>
  .upload {
   position:relative;
   width:250px;
   height:135px;
   border:1px solid #666;
   padding:10px;
   background:#DDD;
  } 
  .loading {
   background:rgba(50,50,50,0.8);
   position:absolute;
   top:0;
   left:0;
   width:250px;
   height:135px;
  }
  .realupload {
   position:absolute;
   bottom:0;
   right:0;

   /* start of transparency styles */
   opacity:0;
   -moz-opacity:0;
   filter:alpha(opacity:0);
   /* end of transparency styles */

   z-index:2; /* bring the real upload interactivity up front */
   width:200px;
  }
  form .fakeupload {
/*   background:url(uploadify/select.png) no-repeat 100% 50%;
*/  }
  form .fakeupload input {
   width:238px;
   font-family:Arial,sans-serif;
   padding:5px;
   border:1px solid #666;
   background:#FFF;
   outline:none;
  }
  label {
   width:120px;
   height:30px;
  }
  label img {
   cursor:pointer;
  }
  .upload a.cancel {
   position:absolute;
   top:10px;
   right:10px;
  }
 </style>
</head>

<body>
<div class="upload">
<form name="file" method="post" action="test.php" enctype="multipart/form-data">
 <label for="realupload"><img src="uploadify/select.png" /></label>
 <div class="fakeupload">
  <input type="text" name="fakeupload" /> <!-- browse button is here as background -->
 </div>
 <input type="file" name="upload" id="realupload" class="realupload" onchange="this.form.fakeupload.value = this.value;" />
 <input id="submit" type="submit" name="submit" value="Submit" />
</form>
<a class="cancel" href="test.php"><img src="uploadify/cancel.png" /></a>
<div class="loading"></div>
</div>
<script>
 $(document).ready( function() {
  $('div.loading').fadeOut(0);
 });
 $('form input.submit').click( function() {
  $('div.loading').fadeIn(400);
 });
</script>
</body>
</html>

这取决于浏览器的安全级别。我在Windows IE上遇到过这种情况,但令人惊讶的是,你在Mac上。尝试其他浏览器或更改当前浏览器的安全选项。不要太保守


另外,试着使用其他网站的上传表单。

我在Chrome上得到了这个,但我只是在Firefox上得到了文件名。很奇怪。浏览器组成它自己的dir fakepath必须以我的代码为基础?同样的路径也显示在该页面链接的示例中。非常奇怪!