1 (edited by statiic 2006-04-29 3:56:20 PM)

Topic: [Download]File upload using xajax

HI guys,

I got an piece of script an made it work with xajax.
Most of it I found on the web . I just changed some code that it at least is compatible with an xajax based website.

Now their is one more thing todo for the developers.

I didnt want to mess around with the xajax.js yet. So i leave it for you guys.

This upload is using ajax (combination php + javascript) and is bypassing xajax for the response.
So what I mean. It has its own javascript response included. Its works the same as xajax.
So you guys can include it into your xajax library.

Here are the files : http://www.yourfilelink.com/get.php?fid=92648

Have fun with it. I hope to see this soon included into the xajax library.

Re: [Download]File upload using xajax

Here is the piece of javascript what I am talking about. If you guys can include this into the xajax library and create an new function. Then that would be great.

var http = createRequestObject();
var uploader = '';

function createRequestObject() {
    var obj;
    var browser = navigator.appName;
    
    if(browser == "Microsoft Internet Explorer"){
        obj = new ActiveXObject("Microsoft.XMLHTTP");
    }
    else{
        obj = new XMLHttpRequest();
    }
    return obj;    
}

function traceUpload(uploadDir) {
         
   http.onreadystatechange = handleResponse;

   http.open("GET", 'imageupload.php?uploadDir='+uploadDir+'&uploader='+uploader); 
   http.send(null);   
}

function handleResponse() {

    if(http.readyState == 4){
        document.getElementById(uploaderId).innerHTML = http.responseText;
        //window.location.reload(true);
    }
    else {
        document.getElementById(uploaderId).innerHTML = "Uploading File. Please wait...";
    }
}

function uploadFile(obj) {
    var uploadDir = obj.value;
    uploaderId = 'uploader'+obj.name;
    uploader = obj.name;
    
    document.getElementById('formName'+obj.name).submit();
    traceUpload(uploadDir, obj.name);    
}

Re: [Download]File upload using xajax

I found some other scripts. Which is using an different way of uploading without refreshing the pages. It also has an progress indicator. Its only an moving picture, nothing more wink

This script is made too upload pictures, but it can be used for other stuff too if you change the javascript pieces.

http://www.air4web.com/files/upload/source.zip

Re: [Download]File upload using xajax

statiic wrote:

I found some other scripts. Which is using an different way of uploading without refreshing the pages. It also has an progress indicator. Its only an moving picture, nothing more wink

This script is made too upload pictures, but it can be used for other stuff too if you change the javascript pieces.

http://www.air4web.com/files/upload/source.zip

Im building an image gallery for my cms. I think ill stick to the example statiic posted. The problem is, i also need to give title/description for each photo. Any ideas on how to do it?

Using xajax 0.5

Re: [Download]File upload using xajax

Submit an var to the javascript function with the name in it. And give the javascript function an extra output for the line.

Re: [Download]File upload using xajax

Sorry i forgot to write extra info.
The -panorama- is actually this:

My CMS manages a news module with tiny_mce, as well as a content editor for all the sections (with tiny_mce), and then the photo gallery.

I was thinking on uploading all the photos for the news/content/gallery with the air4web uploader you posted about. The problem is, as you can see, that different modules use the exact same uploader, but only the gallery needs the title/description option.

The solution you just provided works for the gallery (thanks)... but what can i do for the tiny_mce? is there a way to integrate both of them?

Using xajax 0.5

Re: [Download]File upload using xajax

I dont see the problem. Just add an textarea and make sure that one gets submitted too. Tiny_mce will integrate itself if you just put the code in the head.

Or do you mean something else???

Re: [Download]File upload using xajax

statiic, what kind of tiny_mce integration are you talking about? you mean putting the whole air4web uploader inside a tiny_mce -image-manager-kind-of popup? or just to place the air4web below the tiny_mce textarea in order for the user to drag-drop the pics?

Using xajax 0.5

9 (edited by Pavel 2006-07-23 6:09:50 PM)

Re: [Download]File upload using xajax

http://www.air4web.com/files/upload/source.zip - this uploader looks just what I need, thanks!

a problem, though - IE and FF give out a JS error, Opera works fine
useless setTimeout call (missing quotes around argument?).... line 28, upload.php,
that's the line:

setTimeout(document.iform.submit(),5000);

I also read this: http://developer.mozilla.org/en/docs/Ta … etInterval

so, what do you think is there's solution to this?

Re: [Download]File upload using xajax

just change it to

setTimeout("document.iform.submit()",5000);

Re: [Download]File upload using xajax

well, anyway he's got different code in source.zip in actual app on his server. I wrote a message in ICQ to him, but he never answered... source.zip is not working for me, though.

Re: [Download]File upload using xajax

Wrote an message to me in icq?? I dont have icq.

And I was on vacation for the last few weeks. So I was kinda inactive around here wink

Anyway  I dont have other scripts then that. It works on my system, but check out the other topic about file uploading. I posted there an script which works with xajax 0.2.4.

Re: [Download]File upload using xajax

Statiic, I need help about uploading !
In fact I used your script above and I thought it was OK , everything was fine in local with xampp .... and about a few try, sometimes it didn't work ....
So I try to put it to a server (wich use also xampp) and in fact my problem is here :


function handleResponse() {

    if(http.readyState == 4){
        document.getElementById(uploaderId).innerHTML = http.responseText;
        //window.location.reload(true);
    }
    else {
        document.getElementById(uploaderId).innerHTML = "Uploading File. Please wait...";
    }
}

The end of the request is not the end of the uploading. How to detect that the file has finished to be uploaded ???
Because in fact, I need to upload the file and then I rename it in php (unique_number_$filename) and put the path to my database.
Please help !
In advance thank you.
Vincent

Re: [Download]File upload using xajax

Did you also copied the cgi file into your cgi-bin???

Re: [Download]File upload using xajax

I don't talk about cgi file. but just about your exemple :
http://www.yourfilelink.com/get.php?fid=92648
which doesn't contain any cgi files

I know that there is an other example with cgi file but I can't it make work.
If you can send it an example with cgi file which works, that ok for me. Apparently you use the same configuration as me. (windows with xampp)

Re: [Download]File upload using xajax

The script above is really old. And yes it doesnt work. In the other topic you can just copy paste the code if you have linux. And if you have windows you only need to make an few changes which I wrote down wink

17 (edited by tpneumat 2007-03-26 4:28:15 PM)

Re: [Download]File upload using xajax

For a recently upload utility with xajax, you can check out my script at:

http://trydobe.com

Thanks,

tpneumat