简体   繁体   English

如何使用 html、javascript、php 获取上传的文件路径

[英]how to get the uploaded file path using html , javascript , php

I am uploading am image from my drive, it is uploaded successfully but I am unable to get the folder path of that image我正在从我的驱动器上传图像,它已成功上传,但我无法获取该图像的文件夹路径

for example:例如:

E:\Allied logo\Allied Logo images E:\Allied 标志\Allied 标志图片

$('#pngfile').change(function (e) {
var tmppath = URL.createObjectURL(e.target.files[0]);
console.log(this.files,tmppath);
        })

It'll give you a temporary path not the accurate path, you can use this script if you want to show selected image.它会给你一个临时路径而不是准确的路径,如果你想显示选定的图像,你可以使用这个脚本。

Here is the code:-这是代码: -

HTML:- HTML:-

<input type="file" id="i_file" value=""> 
<input type="button" id="i_submit" value="Submit">
<br>
<img src="" width="200" style="display:none;" />
<br>
<div id="disp_tmp_path"></div>

JS: - JS: -

    <script type="text/javascript">
    $('#i_file').change( function(event) {
        var tmppath = URL.createObjectURL(event.target.files[0]);
        $("img").fadeIn("fast").attr('src',URL.createObjectURL(event.target.files[0]));
    
        $("#disp_tmp_path").html("Temporary Path(Copy it and try pasting it in browser address bar) --> <strong>["+tmppath+"]</strong>");
    });
   </script>

Jquery Jquery

<script type="text/javascript"> 
  $(function(){
    
            $('#fiad').change( function(event) {
                                                    var tmppath = URL.createObjectURL(event.target.files[0]);
                                                    $("img").fadeIn("fast").attr('src',tmppath);
                
            });
  });  
  </script>

Html Html

<input type="file" id="fiad"><br><br>

<img src="" width="200" style="display:none;" />

you get file path inside tmppath here.您在此处获得tmppath内的文件路径。

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

相关问题 上载的文件名是通过HTML和Javascript的路径 - Uploaded file name is path via HTML and Javascript 如何使用javascript或jquery将上传的文件存储到服务器路径中 - How to store uploaded file into server path using either javascript or jquery 如果使用ajax jquery文件上载来上传文件,如何在php中获取上载的文件名 - How to get the Uploaded file name in php if the file is uploaded by using ajax jquery file upload 使用php脚本上传文件,并使用上传的文件(名称)打开html页面和javascript - Upload a file using php script and open html page wit javascript using uploaded file (name) 如何在reactjs中获取上传文件的路径 - how to get the path of an uploaded file in reactjs 使用PHP和Javascript编辑上传的PDF文件 - Editing uploaded PDF file using PHP and Javascript 如何使用javascript从php文件获取file_get_contents的路径 - how to get the path of file_get_contents from a php file using javascript 如何获取未知文件路径 - 扩展路径 - 使用 Javascript? - How to get unknown file path - the extension path - using Javascript? 如何使用php读取/提取文本文件的值,该文本文件以html形式上传到另一个文本文件中? - how to read/extract the values of a text file which is uploaded on to a html form into another text file using php? 如何使用JavaScript读取上传的xml文件? - How to read uploaded xml file using javascript?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM