Javascript将$

编程入门 行业动态 更新时间:2024-10-23 12:27:52
本文介绍了Javascript将$ _FILE ['file']发布到php的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

有人可以帮我解决这个问题,我试图改变我的文件上传方案以使用JavaScript,这样我的页面就不会在用户上传文件时提交,谢谢你提前; belove ismy code

< script type = text / javascript > 功能fileUplodBtn(fileID){ $('#'+ fileID).trigger('click'); // alert(fileID); } 函数fileUploder(fileID){ //document.getElementById('addrec')。submit(); // var formData = new FormData($(#myForm)。[0]); //$.post('AddFormLogic.php',formData,function(response) var fileInput = document.getElementById(uploadrecipephoto); $ .post( upload.php,{uploadrecipephoto:'uploadrecipephoto'},函数(数据){ alert(data); }); alert(fileInput .files [0] .size); alert(fileInput.value); alert('得到它'); } < / script > < div id = response > < / div > < 输入 type = file id = uploadrecipephoto value = uploadfile 名称 = file style = visibility:hidden / > < tr > < th align = left > < 输入 类型 = 提交 class = btnLogin name =' btnCreateRecipe' value = 创建配方 / > < / th > < th class = file-upload 对齐 = right > < div id =' file_browse_wrapper' type = 提交 onclick = return false onmousedown = javascript:fileUplodBtn('uploadrecipephoto'); > < 输入 type = 隐藏 name = uploadrecipephoto value = recipephoto > < / div > < / th > < / tr >

和我的PHP方面我有捕手

if (isset($ _ FILES [' file'] [' name'])){ getrecphoto( ); $ fileloc = $ _SESSION [' temprecimg']; echo $ fileloc ; echo ' ------ --------'。$ _ SESSION [' ufolder']; echo ' ++++++ +++'。$ _ FILES [' file'] [' type']; echo ' < script type =文本/ JavaScript的>警报( 22222222); < /脚本>'; }

我一直试图解决这个问题3天了!我知道这看起来很愚蠢,但我不知道如何将文件信息发布到php

解决方案

('#'+ fileID).trigger('click') ; // alert(fileID); } 函数fileUploder(fileID){ //document.getElementById('addrec')。submit(); // var formData = new FormData(

(#myForm)。[0]); //

.post('AddFormLogic.php',formData,function(response) var fileInput = document.getElementById(uploadrecipephoto );

can someone please help me with this code, Im trying to change my file upload scheme to use JavaScript so that my page doesnt get submitted ever time user uploads a file, THANK YOU IN ADVANCE; belove ismy code

<script type="text/javascript"> function fileUplodBtn(fileID) { $('#'+fileID).trigger('click'); //alert(fileID); } function fileUploder(fileID) { //document.getElementById('addrec').submit(); //var formData = new FormData($("#myForm").[0]); //$.post('AddFormLogic.php', formData, function(response) var fileInput = document.getElementById("uploadrecipephoto"); $.post("upload.php",{uploadrecipephoto: 'uploadrecipephoto'}, function(data) { alert(data); }); alert(fileInput.files[0].size); alert(fileInput.value); alert('got it'); } </script> <div id="response"></div> <input type="file" id="uploadrecipephoto" value="uploadfile" name="file" style="visibility: hidden" /> <tr > <th align="left" > <input type="submit" class="btnLogin" name='btnCreateRecipe' value="Create Recipe" /> </th> <th class="file-upload" align="right"> <div id='file_browse_wrapper' type="submit" onclick="return false" onmousedown="javascript:fileUplodBtn('uploadrecipephoto');" > <input type="hidden" name="uploadrecipephoto" value="recipephoto"> </div> </th> </tr>

and on my PHP side I have the catcher

if (isset($_FILES['file']['name'])){ getrecphoto(); $fileloc= $_SESSION['temprecimg']; echo $fileloc; echo '--------------'.$_SESSION['ufolder']; echo '+++++++++'.$_FILES['file']['type']; echo '<script type="text/javascript"> alert("22222222"); </script>'; }

I have been trying to figure this out for 3 days now! I know it seems dumb but i just cant figure outhow to post the File info to the php

解决方案

('#'+fileID).trigger('click'); //alert(fileID); } function fileUploder(fileID) { //document.getElementById('addrec').submit(); //var formData = new FormData(

("#myForm").[0]); //

.post('AddFormLogic.php', formData, function(response) var fileInput = document.getElementById("uploadrecipephoto");

更多推荐

Javascript将$

本文发布于:2023-10-11 23:21:48,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1483126.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Javascript

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!