简体   繁体   English

我正在使用prototype.js将POST内容传递到php脚本,但是文件POST却没有

[英]I'm using prototype.js to pass POST content to a php script but FILE POST doesn't go

I'm using this script to pass my POST contents : 我正在使用此脚本来传递我的POST内容:

<script type="text/javascript">  
// <![CDATA[  
document.observe('dom:loaded', function() {  

    function sendForm(event){  
        // we stop the default submit behaviour  
        Event.stop(event);  
        var oOptions = {  
            method: "POST",  
            parameters: Form.serialize("standardform"),  
            asynchronous: true,  
            onFailure: function (oXHR) {  
                $('feedback').update(oXHR.statusText);  
            },  
            onLoading: function (oXHR) {  
            $('feedback').update('Enregistrement en cours ... <img src="images/throbber.gif" title="Loading..." alt="Enregistrement..." border="0" />');  
            },                            
            onSuccess: function(oXHR) {  
               $('feedback').update(oXHR.responseText);  
            }                 
        };  
        var oRequest = new Ajax.Updater({success: oOptions.onSuccess.bindAsEventListener(oOptions)}, "enregistre-site-marque.php", oOptions);             
    }  
    Event.observe('submitButton', 'click', sendForm, false);              
});   
// ]]>  

But my FILE POST doesn't pass, they are empty in my enregistre-site-marque.php script. 但是我的文件发布未通过,在我的enregistre-site-marque.php脚本中为空。 How can I pass POST content? 如何传递POST内容?

Prototype.js: Form.serialize() Prototype.js:Form.serialize()

"Also, file inputs are skipped as they cannot be serialized and sent using only JavaScript." “此外,文件输入将被跳过,因为它们不能仅使用JavaScript进行序列化和发送。”

see: http://prototypejs.org/doc/latest/dom/Form/serialize/ 参见: http : //prototypejs.org/doc/latest/dom/Form/serialize/

Sounds like you can't AJAX the file this way -- try doing it with a regular form-post, or (if necessary) using a Javascript/ AJAX uploader. 听起来您无法用这种方式AJAX文件-尝试通过常规的表单发布或(如果需要)使用Javascript / AJAX上传器进行处理。

Simple HTML form submit, without AJAX, would probably be the technically simplest & most reliable (thus preferable) solution -- if you can do that. 没有AJAX的简单HTML表单提交可能是技术上最简单,最可靠(因此更可取)的解决方案-如果可以的话。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM