简体   繁体   English

使用Javascript将图像上传到文件夹

[英]Upload images to folder using Javascript

On the admin panel I upload some photos and a thumbnail and on the site I have a digital showcase that is built using javascript in order to grab photos from a folder and display them.在管理面板上,我上传了一些照片和缩略图,在网站上我有一个使用 javascript 构建的数字展示,以便从文件夹中抓取照片并显示它们。 My question is: how can I put the photos after I saved them on that specific folder?我的问题是:将照片保存在该特定文件夹后如何放置? More exactly...how can I upload the images into my folder?更准确地说...如何将图像上传到我的文件夹中?

if(x.showcase_gallery_type=='image'){
$('#modal-popup .content .slide .context ul').append('<li style="text-align:center;padding-left:5px;"><img src="<?=base_url()?
/resources/media/showcase/image/'+x.showcase_gallery_filename+'" /></li>');

Javascript (with uploadify or other tools) can only handle one side of the upload process, namely sending the file. Javascript(使用uploadify 或其他工具)只能处理上传过程的一方面,即发送文件。

To receive the file on the server and save it, you'll have to use server-side technology like PHP, ASP.NET, Python etc.要在服务器上接收文件并保存它,您必须使用服务器端技术,如 PHP、ASP.NET、Python 等。

you should use uploadify你应该使用uploadify

and in the handler( in asp.net for example) you should use并在处理程序中(例如在 asp.net 中)您应该使用

Request.File

and use并使用

the SaveAs function SaveAs函数

using Server.MapPath function使用Server.MapPath函数

if (context.Request.Files == null || context.Request.Files.Count == 0) throw new Exception("error reciving file");

var savedFile = context.Server.MapPath(@"~/Pics/Links/") + guid + ".jpg";
resizedImage.Save(savedFile, System.Drawing.Imaging.ImageFormat.Jpeg);

You might try Plupload which has several options which suits your needs.您可以尝试Plupload ,它有多种适合您需求的选项。

And try this if you need thumbnails to display while uploading如果您需要在上传时显示缩略图,请尝试此操作

http://blueimp.github.com/jQuery-File-Upload/

Note: This dosen't upload multiple files in IE.注意:这不会在 IE 中上传多个文件。

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

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