AJAX Upload
Apr 6, 2006Is there any way to upload file through AJAX?
View 15 RepliesIs there any way to upload file through AJAX?
View 15 RepliesThis Scripts allows you to upload files using AJAX (I'm not an
expert). The site claims it's the best way to upload files out there,
and the file size is only 1 kb.
I couldn't get it to work for me. I downloaded the files to my
computer, and opened the index file with my browser. It doesn't work
(the demo on their site does); IE doesn't show any error messages or
anything, and FF shows a single word that might be treated as an error
notifier: 'undefined'. Does this thing even work? If it does, could
anyone please give me detailed steps on how to using it on my site?
Code:
I've created a PhP page(Main) which will list records and a link to change their "thumbnail". Clicking on it will open a "pop-up" which will present a "File input" box and when user select a file to upload, this popup-page will send the form fields to a "process page" using AJAX. This Process page will upload the file and on success returns nothing else the error to the Ajax object in Popup. On return, the popup page will just reload the thumbnail on main page if success and closes itself.
I'm sure I've described what I wanted to do. Again, in brief: Main->(Opens Popup)->Popup->(Send file using AJAX)->Process Process->(Upload File & return result to)->Popup->(Reload img on Main and closes itself)->Main
Below are my codes:
[Code]...
I used this page for making upload progress bar. I downloaded it and uploaded it to the server (you can see it here), and I signed up to Google Maps API and I pasted the code, but it doesn't work. It uploads the file, but it doesn't write the upload progress
View 3 Replies View RelatedDoes anyone know of an easy to implement ajax upload script for php
which also has a progress bar. If possible I'd like it to be able to
remove already uploaded files and do minor manipulations.
I'm using a script I picked up from elsewhere that allows you to do uploading through AJAX (well, actually through an IFRAME,but lets not get into whether that's really AJAX ). Anyway, the script works great except for one little problem though.Sometimes when it submits the ajax form and gets to the server, my $_POST data is empty.The only correlation I've found is I believe it happens when the file I'm uploading is too big (though I'm not exactly sure what the cut off mark is). Regardless, small files aren't causing problems and large ones mean I have no $_POST data on the server when I get there. Here's the script I'm using:
Code:
/**
*
* AJAX IFRAME METHOD (AIM)[code]....
why this might destroy my POST data?
I have a script which allow users to chnage there profile image, and it allmost works perfect. The script is set up so when a user uploads a new picture it overrides the previous one, so if a user have an ID, lets say 15, the image would be called 15.jpg. The problem is that when an new upload is finished it still shows the old image, I think by cache, and thats no good. How do I refresh the image with ajax so when the script has done uploading the image is the new one?
The javascript upload.js:
Code JavaScript:
<!--
function startUpload(){
document.getElementById('f1_userimage').style.visibility = 'hidden';
document.getElementById('f1_upload_process').style.visibility = 'visible';
[Code]....
Suggest a good easy to use ajax file upload plugin ? I am using Asp.net on server side
View 1 Replies View RelatedI need some way to use ajax to upload a file mainly a image and a video to my website.
I googled around and found many people saying it's impossible to do it with ajax.. but there are jquery work around plugins where it uses an hidden ifframe to submit your files.
what is the best and simple way to do this task?
I am trying to upload a file and text using jquery ajax. The upload would include validation that is done with php and echoed on a div on the uploading page.
View 2 Replies View RelatedLast year, just a few days before holidays, I wrote a tutorial about a new feature available in Firefox 3 that allows web developers to do AJAX-style file uploads. Initially I intended to publish this tutorial as a SitePoint article, but it got rejected so I published it on my blog.
Now, I'd love some feedback. So, if there's anyone out there that has enough patience to read an exhaustive tutorial about uploading files with nothing more than JavaScript I'd like to hear her/his opinion. If it's crap just tell me 'cause indifference kills. Anyway, if patience is not your strong point there's a ZIP package containing both a "simple" and a "complex" take on the problem. Try those.
I wanted to do an Ajax script to resize and preview and image in an html form. Well, I didn't find how to do with Ajax, so I had to use php.The issue is that JavaScript cannot manage a file field to get the selected file and send it via Ajax. The only way to send a file is submitting a form. To not send all data of the form, the file field must be a separate form from the rest of the data. So it can be automatically sent to a php script, which resizes the image, uploads it and then can display it in a iframe without reloading the page.
Then you have the resized image previewed in the form without submitting all data. And then you can send all data with Ajax, including the path of the previously uploaded image, which is stored as a variable in the iframe.I use one html file and two php scripts, which in total are less than 20 KB.
Before I waste time trying to achieve this, could someone possibly tell me whether it is in fact possible to upload an image using the jquery ajax function?I have seen examples on google but they are not too clear how they achieve it.
View 5 Replies View RelatedI'm actually new on jquery ajax. I just wanna ask a little idea about how to create simple file upload (with form) using ajax. I tried using this code:
//form html
<p id="status"></p>
<form id="form1" enctype="multipart/formdata">
<input type="file" id="photo" name="photo" />
<input type="submit" id="save" name="save" value="Upload" />
</form>
//php file
if($_POST){
$name = $_POST['photo']['name'];
$tmp = $_POST['photo']['tmp_name'];
$path = "images/".basename(name);
if(move_uploaded_file($tmp,$path)){
print("Done! File saved...");
}else{
die("Error on uploading!")
}}
//js
$(document).ready(function(){
var photo = $("#photo").val();
$.post("upload.php",{photo:photo},function(data){
$("#status").html(data);
});});
I've a technical problem, i use jQuery Form Plugin and it's working well except for upload file. Effectively after uploading file we can't see any response in firebug. (You can see an example in the official website of jquery form plugin [URL] And in the response i call a script with
<script src="script.js" type="text/javascript"></script>
My page get this file well but i have a javascript error on the "$" of
$(document).ready(function() {...
I am trying to implement this jQuery form plugin to do ajax file uploads. Although the documentation is great I am still a little unclear about one thing. Usually when I do ajax submissions I return a response in JSON(using PHP), something like :
<?php
echo json_encode(array("status_message"=>"success"));
?>
When doing some simple tests I have run into a problem and I believe it is due to the way this plugin handles JSON responses. My form :
[Code]...
This does not result in the success event firing but rather the error event. In the plugin documentation it states that it does not handle json responses well and that it recommends wrapping the response in a textarea. Unfortunatly I'm not sure what they mean by that, and what I've tried so far has not worked. ould anyone give me some advice as to how to output the response in JSON properly? Could anyone that has used this plugin for AJAX file uploads offer any advice on doing so?
I'm using AJAX for all the updates to the web site I'm building and it works very well. But now I face the need to:
1) Upload a file (an image or video) to a folder in the server.
2) Insert a row in MySQL with the name of the file plus some other information (year and a comment).
The user would upload the file and fill in the information in the same window, and should have a single message (if possible) saying that the file was added or not (meaning both the upload and the insert).I have been doing some googling and found information as how to simulate and AJAX upload, since it seems AJAX does not support file uploads (hope I'm wrong). This is what I found: [URL]
So following that example I could upload the file, and I'd have all the information from the form, in the PHP, and I could synchronize the upload and the insert, but then I can't figure out how to send the OK from the PHP to a Javascript (i guess) to update the html and display the message in the web site.
I'm amending an upload script from Max's AJAX file uploader. [URL] I wish to display the filename after the file uploaded. The text in green are added by myself. However, I failed to display success status after the upload process successful. Do you know where I made the error?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Max's AJAX File Uploader</title>
<link href="style/style.css" rel="stylesheet" type="text/css" />
[Code]....
I'm using AJAX for all the updates to the web site I'm building and it works very well. But now I face the need of:
1) Upload a file (an image or video) to a folder in the server
2) Insert a row in MySQL with the name of the file plus some other information (year and a comment).
The user would upload the file and fill in the information in the same window, and should have a single message (if possible) saying that the file was added or not (meaning both the upload and the insert).
I have been doing some googling and found information as how to simulate and AJAX upload, since it seems AJAX does not support file uploads (hope I'm wrong). This is what I found:
So following that example I could upload the file, and I'd have all the information from the form, in the PHP, and I could synchronize the upload and the insert, but then I can't figure out how to send the OK from the PHP to a Javascript (i guess) to update the html and display the message in the web site. And anyway, is this the right approach to do what I need?
The script calls the php file without a problem when the submit key is hit. However, it doesnt post the form data with it. The HTML form
[Code]...
I need to upload image without refreshing a page and show the progress of uploading.How can i do it?
View 1 Replies View RelatedI have following code, that i am sure can be done in 1 single function, which will ease extending it in future.
Basically when a link is clicked, i wante the upload form to apear....and any other upload forms to disapear.
How can i put those 3 functions in 1?
i want to do (multiple) file upload(s) and display a progress bar.
with firefox and safari it is no problem at all. only IE makes some
problems.
my script is based on ajax-uploader, which can be found at
www.srmiles.com/freestuff/ajax_file_uploader/ . you can do multiple
file uploads. each upload will have it's own "form"-tag, so that each
file is uploaded for its own. could be a good solution if there are
"big" uploads.
so here is what i do:
i have a html-page in which several forms with file-input fields are
generated. when i now hit the "one" submit button at the bottom of the
page a javascript function upload() starts it will iterate through all
forms (id='frmUpload_xx'), will get the filename, start a ajax request
for the progress-bar function and do a form.submit().
if the first form/file is uploaded, a settimeout('upload()', 1000); is
called and the next form will be processed. all form's have an
target="uploaddiv", where uploaddiv is a invisible iframe. so the
output of the upload script is put in this div. output should only be
a "OK" at the end. no usefull output no info no nothing.
firefox and safari are working as expected, only IE stops after the
first file is uploaded. i get an javascript error saying "zugriff
verweigert/access denied" on object line x... this is the place where
i call "form.submit()".
this is the upload-function:
function upload() {
if (uploads.length>0) {
form = document.getElementById('frmUpload_'+uploads[0]);
if (form["filename"].value == ""){
alert("Please Choose a file to upload.");
} else {
filename = form["filename"].value;
if (filename.lastIndexOf("")>0) {
filename = filename.substring(filename.lastIndexOf("")
+1,filename.length);
} else if (filename.lastIndexOf("/")>0) {
filename = filename.substring(filename.lastIndexOf("/")
+1,filename.length);
}
makeRequest("upload_progress.php?sid="+sid
+"&filename="+filename,progress);
form.submit();
}
}
}
the strange thing is, that filename is filled correct, that means the
object "form" is found and exisits. the first iteration is working,
only the second ends with an error.
think it have something to do with redirecting the output of the
upload-script in an iframe. after that IE can't access form - at least
IE is not allowed to submit the form as i can access a form field
(filename).
i worked on that the last two days and haven't found a solution...
I am looking for a upload form to upload pictures and then when the pictures are uploaded, then they get emailed to me. Kind of like a contact form but attached is the pictures.
View 1 Replies View RelatedI implemented Malsups jquery form and use it for ajax file uploads. Works fine in FF, but in IE as soon as the ajax has completed the upload IE gives me a File Download box - Security warning. If I click on save it save thereturnedJson object (I do JS call onsuccessto get a file list and display it). If I click cancel or save on the popup has same effect the file still gets uploaded but just looks ugly.
How can I get rid of this? All coming form the same domain, calling from the same domain. This is on a python django project and I am testing it on the dev server.
Its pretty basic jquery nothing to exciting, don't get why IE would cause.
I develop a form allow the user to upload with the hidden iframe.
While in the progress, I allow the user to cancel their upload. In
javascript, does it have cancel the request to the server. I have one
solution, but I don't like it. I remove the iframe element, so it
won't upload anymore. Do you any other solutions better than this?