开发者

jQuery post upload file

开发者 https://www.devze.com 2023-03-29 01:32 出处:网络
I have a image upload form which adds an image to my server, although I\'m wanting to load the information through jQuery ajax so the form doesn\'t refresh on submit.

I have a image upload form which adds an image to my server, although I'm wanting to load the information through jQuery ajax so the form doesn't refresh on submit.

At the moment I have

     $('.img-form').submit(function(e) {
e.preventDefault();
$.post(document.href, $(".img-form").serialize());

});

Which seems to post the document, although i need to get it to call my ImageUpload() function from the PHP once I've pressed the submit.

My php function is calle开发者_StackOverflowd something like this,

<?php $Users->TutorialImageUpload(); ?>


If I understood correctly, you wish to upload an image without refreshing the page, and call your imageUpload() function.

As mentioned in the comments, you cannot upload in such a manner, however, what you could do is put your upload form and code in a seperate php file and include it in the page as an iframe. This would upload your files withough refreshing the page.

0

精彩评论

暂无评论...
验证码 换一张
取 消