简体   繁体   English

html表单-在没有php的情况下将文件上传到存储

[英]html form - upload file to storage without php

All the exmaple I saw was with a form that redirect to file upload.php. 我看到的所有精彩片段都是带有重定向到文件upload.php的表单。 I want to do a little differnt. 我想做一点区别。

I have a form and there I have : 我有一个表格,那里有:

<input type="file" name="img1"  id="img1">

and in the end of the form: 并在表格末尾:

<button type="button" class="submit-button" onclick="signUp()"/> signup </button>

I want in the signUp() function to store the file in my storage and get url to thiss file. 我想在signUp()函数中将文件存储在我的存储中,并获取此文件的url。

What I did so far is : 到目前为止,我所做的是:

 var fileUploadControl = $("#img1")[0];
if (fileUploadControl.files.length > 0) {

  var file = fileUploadControl.files[0];

......................

}

but I don't know how to continue. 但我不知道如何继续。 thanks! 谢谢!

It is not possible to store data/file without using a server side language(like PHP,C#,...). 如果不使用服务器端语言(如PHP,C#等),则无法存储数据/文件。 Else anyone could save files to your server and that is something you don't want! 否则任何人都可以将文件保存到您的服务器,这是您不想要的!

I recommenced to use a combination of HTML and PHP! 我建议同时使用HTML和PHP! You will find a good documentation on http://www.php.net/manual/en/features.file-upload.post-method.php 您可以在http://www.php.net/manual/zh-cn/features.file-upload.post-method.php上找到很好的文档

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

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