简体   繁体   中英

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. 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.

To receive the file on the server and save it, you'll have to use server-side technology like PHP, ASP.NET, Python etc.

you should use uploadify

and in the handler( in asp.net for example) you should use

Request.File

and use

the SaveAs function

using Server.MapPath function

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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