Re: File Uploading - A possible attempt

Save images in the database??

You need to save them to your harddrive and save the link into the database.

77 (edited by hifi 2006-08-09 1:35:44 PM)

Re: File Uploading - A possible attempt

I was thinking to save in db BLOB. Now I will save on the harddrive.
Shall I hope for some working code on windows? smile

Thanks in anticipation,
hifi

78 (edited by dev 2006-08-13 3:45:43 AM)

Re: File Uploading - A possible attempt

I had to change this line in the php otherwise the bar never gonna stop!
function upload_progress ....
remove this
if($percentage===0||$percentage===100){
sleep(1);
}
by this one:
if($percentage===100){
         return $objResponse;
}
In addition the cgi is generating trash I mean tmp files with 0 bytes. To correct this better use:
(cgi file line 108+-)

$upload_tmp_dir=realpath($upload_tmp_dir);
     $pos= stripos($upload_tmp_dir, '\\');
    if(pos!=false){
    $upload_tmp_dir.='\\';
    }else{
    $upload_tmp_dir.='/';
    }//these files check if OS is windows or linux and add the correct simbol at the end
   
    //To write the file
    $tmp_name = $upload_tmp_dir.$uid.'tmp';
    $out = fopen($tmp_name, 'w');
    fwrite($out, $body);
    fclose($out);
----------------------------------------------
To move the file you have two options:
1. php file:
if($percentage===100){
->you must add the code in section to move the file
         return $objResponse;
}
2.cgi file
at the end (before exit()):
echo ('<script type="text/javascript">
  window.parent.xajax_myfunctiontomove.'("'.$sourcename'","'.$tmpname.'");

</script>
');

I've tested this script in windows and linux and works perfect!
Thanks BBC!

Re: File Uploading - A possible attempt

dev wrote:

remove this
if($percentage===0||$percentage===100){

Ah, but what happens when you upload from the same <input> twice.  The if ($percentage is 0) is to make it keep checking in case the function is called before the file starts uploading from some thread race problem.

Re: File Uploading - A possible attempt

The bar keeps on loading??? It doesnt in my script.

81 (edited by dev 2006-08-13 10:39:43 PM)

Re: File Uploading - A possible attempt

remove this
if($percentage===0||$percentage===100){
Well for my is working without ===0 (I use only one file per time and when is done a change ids) but The only problem that I have is with the stop function because that is not killing the process, BBC exists some way to kill the previous state (threat)  something like:
xajax.realCall = xajax.call;
xajax.call = function(sFunction, aArgs, sRequestType)
{
-----if exist previous upload kill that-----
}
Because the stop button is only to clear the iframe but not the threat!
Thanks!

Re: File Uploading - A possible attempt

so you only want to be able to upload one file at a time?
can you explain a little more what you mean about "not killing the process"?

Re: File Uploading - A possible attempt

First of all this script works with IE for me but not in firefox.
In fact I have a "window.parent" issue .... I used this line at the end of the cgi :
echo "<script type='text/javascript'>window.parent.xajax_WriteInBase('".$nom."','".filesize($thisfile['tmp_name'])."','".mime_content_type($thisfile['tmp_name'])."');</script>";
and it doesn't work in firefox. I'll try to find a solution ... if you have some suggestion you're welcome ;-)

But for now, about the bar which keeps loading I have the same problem if I keep my image animation which shows that there is a xajax request :

xajax.loadingFunction = function(){xajax.$('LoadingImgUpload').style.display='inline';
xajax.$('LoadingImg').style.display='block';};

I remove it and it's ok. That is my solution for now ;-). Maybe you have something better !

84 (edited by dev 2006-09-01 12:46:49 AM)

Re: File Uploading - A possible attempt

I'm using FFox and works fine, I have a question on linux when is php installed as module the php binary doesn't exist example:
The only module available that I found is: /usr/lib/apache-extramodules/mod_php5.so
Therefore the cgi doesn't find the binary.
some solution in mind or is better rewrite a new one in C?

Re: File Uploading - A possible attempt

Following is a link to a open source project- Relay: http://ecosmear.com/relay/ . Relay is doing ajax file upload thingy.

-V

Re: File Uploading - A possible attempt

Hi,
I didn't manage to see where is the problem with Firefox.
At the end of the upload.cgi I put this line :
echo "<script type='text/javascript'>window.parent.xajax_WriteInBase() ...."
to call my xajax function. It's working properly with IE. But I obtain a 404 error with Firefox.
Anybody has an idea ?

Re: File Uploading - A possible attempt

Hi,

dont know if it got mentiont earlier.
see this approch i found while poking around in the net.

http://tomas.epineer.se/archives/3

Rufinus

Re: File Uploading - A possible attempt

Hi guys,

I'm coming to a point where I need a possiblity to upload a file and maybe you understand that I don't have the nerve to read 4 pages of discussion...
Can anyone present the results in the wiki like "3 possibilities to upload files with xajax"? This would be very great :-)

Thank you very much and be creative,

Creativebyte

89 (edited by mstar 2006-09-15 7:44:10 AM)

Re: File Uploading - A possible attempt

Can anyone present the results in the wiki like "3 possibilities to upload files with xajax"?

Great idea.

I've started the new section for this and going to add my solution we use in ourdeployed web applications.

Here it is: http://wiki.xajaxproject.org/index.php? … ile_Upload

There is a link on main wiki page (in 'Tips and Tricks' section).

Feel free editing it and adding your solutions. I'm sure there are a lot of them for now.

We need just share them in our community.

Re: File Uploading - A possible attempt

Finally a summary
check it out.
http://community.xajaxproject.org/viewt … 100#p10100

91 (edited by blubi 2006-10-21 1:12:58 AM)

Re: File Uploading - A possible attempt

nice, waitin' for this a long time... thx alot

mom... you should add this to the cgi script:

while($cur_size < $total_size)
{
    $chunk = fread($stdin, $chunk_size);
    if ($cur_size == $cur_size + strlen($chunk)) exit; // otherwise the cgi'd keep running if the user cancels the POST
    $contents .= $chunk;

Re: File Uploading - A possible attempt

Hm... i tried the cgi-script, but finally it didnt´t worked.
The problem is, that there is no data send through php://stdin...
I think the rest is working.

Perhaps you have any solutions for my problem?

Re: File Uploading - A possible attempt

Hi BBC

I would like to try your upload.cgi.

Is there a working link?  The link in this thread is broken.  Do you still need a Linux server to test from?  I have a spare.

r

94 (edited by tpneumat 2007-03-21 3:51:52 PM)

Re: File Uploading - A possible attempt

Hi All.  I decided I would try to give something back to xajax by way of working out an easy to implement xajax upload utility.  Yes, it does use the iframe with cgi solution, but you will hardly notice it because the setup is mostly all done in php. Hope you like it.  Please add comments to my site and let me know what else i can do to make it work better.

Thanks!!

http://trydobe.com/?page_id=3

Re: File Uploading - A possible attempt

Thats a pretty cool upload thingee smile  Tis a shame tho that its not pure PHP (using perl for the cgi script) sad  But whatever works is good, right?

Re: File Uploading - A possible attempt

But with IE7 progress bar does't show progress.

Sorry for my bad English

Re: File Uploading - A possible attempt

6epcepk wrote:

But with IE7 progress bar does't show progress.

I will work on that.   Check back later.

Re: File Uploading - A possible attempt

6epcepk,

I didn't find an issue with the progress bar in IE7.  Make sure you are uploading a file large enough that it takes some time to upload.  I am going to put another demo up with a slower speed setting at some point.  I did find an error in IE7 in the file viewer on the page.  Somebody uploaded a file with special chars in it.  I guess I need to consider that in my file viewer and accommodate it.

Re: File Uploading - A possible attempt

tpneumat,
I loaded enough the big file for mine the Internet-channel. I see changes: the conductor of the loaded files began to be displayed. Below I result a picture:
http://img250.imageshack.us/img250/3153/bugre6.th.gif

I have established a script locally, but at loading a file there is a creation in a directory for loading six files, the initial file does not appear. In what there can be a reason?

Sorry for my bad English

Re: File Uploading - A possible attempt

6epcepk,

I am having some trouble understanding you.  But, I would like to help.  I am not sure exactly what your problems are.  The picture you sent showed the state right after pressing upload, but before any status info is returned back from the server.  I am wondering if we don't have a timing issue because you are so far away.  I could setup another demo with different timing settings to allow a longer delay, but I don't know if that would help.

Question for you:  How does it end up if you just let it run?  Does it stay on that screen that you are showing here?  Or is there an error such as "Upload Failed?".  Please let me know.

As far as the other question about setting it up locally, the way it works is:

4 files will apear in the temp folder during the upload.  These 4 files include all information for the uploading of any number of files.  All the post data will pile into 1 file called ###_postdata.  The other files are used to contain various information on the files such as filenames in _qstring and file length in _flength.  _signal tells php when the file is done, and _err causes php to return an error to the client.

Once the script completes, the original file[s] is/are manipulated by whatever script you design for that purpose.  You must define what you want to do with the files using:

function fileAction($fileArr){

The upload_config_inc.php provided with the download from my site has an example fileAction function that simply takes the files and moves them to another folder on the server.

rename($fileArr['tmp_name'][$x],"/var/www/uploadtest/".$fileArr['name'][$x]);

This means that you can find the original file with its original name in /uploadtest on the server after the upload is completed. 

Sorry, I thought this would be easier to implement than it appears to have turned out to be.  It really helps if you can read the comments in the config files, especially for fileAction funciton.

Thanks,

tpneumat (Jeremy Dill)