JS图像上传失败OSX Localhost

JS图像上传失败OSX Localhost

问题描述:

I have a site that has a basic image upload. It is executed by JS code. I can post the code here, but it is quite extensive; so I refrain for now. When I try to upload, it works normally and the progress bar runs an appropriate amount of time. However, when I inspect the entries in the MySQL DB's "photos" table, I find that the entries are created there, but most of their fields are NULL. In particular, fields containing the file path and temporary file path are empty.

Does this sound like a permission problem? I am running a basic Mac setup with out-of-the-box Apache and services. I also have some virtual hosts configured but am unsure of whether the affect anything. What else can be causing this?

Edit: Here is the HTML of the form that has user controls for the upload.

<div class="fileUploadForm" id="fileUploadForm-Device">

<div>

    <h3>Upload Photos</h3>

     <p id="deviceFilesDropZone"><span id="drag-drop-text">DRAG AND DROP YOUR PHOTOS HERE</span> <br /><span id="deviceFilesInfo" style="display: none;">0 photos</span><br /><span class="btn" style="display: inline-block; margin-top: 15px;">Browse Photos</span></p>

    <div style="display: none;">
    <div class="uploadLoadingBar" id="uploadLoadingBar"><div class="bar"></div><p id="uploadProgressText"></p></div>
    </div>

    <p style="display: none;"><input id="filePicker" type="file" accept="image/*" name="filePicker" multiple /></p>

    <hr />

    </div>
</div>

There is also the following declaration in the <script> section right below:

var target = document.getElementById("deviceFilesDropZone");

var deviceFiles = new Array();
var totalDeviceFileSize = 0;
var totalDeviceBytesUploaded = 0;
var deviceUploadStartTime = Math.round(new Date().getTime()/1000);
var currentTempStatusIndex  = 0;
target.enctype = "multipart/form-data";

As you can see, I tried adding the set for enctype and the same problem still persists.

我有一个基本图像上传的网站。 它由JS代码执行。 我可以在这里发布代码,但它非常广泛; 所以我现在克制。 当我尝试上传时,它正常工作,进度条运行适当的时间。 但是,当我检查MySQL DB的“照片”表中的条目时,我发现在那里创建了条目,但是它们的大多数字段都是NULL。 特别是,包含文件路径和临时文件路径的字段为空。 p>

这听起来像是权限问题吗? 我正在使用开箱即用的Apache和服务运行基本的Mac设置。 我也配置了一些虚拟主机但不确定是否会影响任何东西。 还有什么可能导致这种情况? p>

编辑 strong>:以下是具有上传用户控件的表单的HTML。 p>

 &lt; div class =“fileUploadForm”id =“fileUploadForm-Device”&gt; 
 
&lt; div&gt; 
 
&lt; h3&gt;上传照片&lt; /  h3&gt; 
 
&lt; p id =“deviceFilesDropZone”&gt;&lt; span id =“drag-drop-text”&gt;拖放您的照片&lt; / span&gt;  &lt; br /&gt;&lt; span id =“deviceFilesInfo”style =“display:none;”&gt; 0张&lt; / span&gt;&lt; br /&gt;&lt; span class =“btn”style =“display:inline  -block; margin-top:15px;“&gt;浏览照片&lt; / span&gt;&lt; / p&gt; 
 
&lt; div style =”display:none;“&gt; 
&lt; div class =”uploadLoadingBar“  id =“uploadLoadingBar”&gt;&lt; div class =“bar”&gt;&lt; / div&gt;&lt; p id =“uploadProgressText”&gt;&lt; / p&gt;&lt; / div&gt; 
&lt; / div&gt; \  n 
&lt; p style =“display:none;”&gt;&lt; input id =“filePicker”type =“file”accept =“image / *”name =“filePicker”multiple /&gt;&lt; / p&gt;  
 
&lt; hr /&gt; 
 
&lt; / div&gt; 
&lt; / div&gt; 
  code>  pre> 
 
 

此处还有以下声明: 下面是&lt; script&gt; code>部分: p>

  var target = document.getElementById(“deviceFilesDropZone”); 
 
var deviceFiles = new Array(  ); 
var totalDeviceFileSize = 0; 
var totalDeviceBytesUploaded = 0; 
var deviceUploadStartTime = Math.round(new Date()。getTime()/ 1000); 
var currentTempStatu  sIndex = 0; 
target.enctype =“multipart / form-data”; 
  code>  pre> 
 
 

如您所见,我尝试为enctype添加set并遇到同样的问题 仍然存在。 p> div>

Make sure that your form has the attribute enctype="multipart/form-data"

It sounds like that is the cause