Jump to content

Ajax copy File Directory


morrisjohnny

Recommended Posts

using AJAX & PHP i need to copy a whole directory.Here is currently my code in PURE PHP

function full_copy( $source, $target ) {	if ( is_dir( $source ) ) {		@mkdir( $target );		$d = dir( $source );		while ( FALSE !== ( $entry = $d->read() ) ) {			if ( $entry == '.' || $entry == '..' ) {				continue;			}			$Entry = $source . '/' . $entry; 			if ( is_dir( $Entry ) ) {				full_copy( $Entry, $target . '/' . $entry );				continue;			}			copy( $Entry, $target . '/' . $entry );		} 		$d->close();	}else {		copy( $source, $target );	}}if(file_exists($url)) //part A		echo '<p style="color:#FF0000;">Sorry This Directory Already Exists</p>';else{	mkdir($url);	$source =substr($_SERVER['SCRIPT_FILENAME'], 0, strrpos($_SERVER['SCRIPT_FILENAME'],'/')).'/common';	$destination = substr($_SERVER['SCRIPT_FILENAME'], 0, strrpos($_SERVER['SCRIPT_FILENAME'], '/')).'/'.$url.'/';	full_copy($source, $destination);}

Now this script works fine untill the 60seconds passes and the max tiem of the php is reached, so this needs to be in ajax, anyone any ideas how to do this? Thanks VERY much !

Link to comment
Share on other sites

using AJAX & PHP i need to copy a whole directory.Now this script works fine untill the 60seconds passes and the max tiem of the php is reached, so this needs to be in ajax, anyone any ideas how to do this? Thanks VERY much !
I'm not sure if AJAX will solve this or not. I think you're hitting the max_execution time limit in your PHP installation, so you may need to increase that.
Link to comment
Share on other sites

Even if you use AJAX, you still need something to accept the file on the server.

Link to comment
Share on other sites

You can use the set_time_limit function to set the time limit in your script, if you set it to 0 it will have no time limit. Of course, in addition to PHP's timeout there's also Apache's timeout and the ajax request timeout.

Now this script works fine untill the 60seconds passes and the max tiem of the php is reached, so this needs to be in ajax
Ajax doesn't have any effect on PHP's timeout, in fact it introduces an additional timeout. The server enforces PHP's timeout, not the browser.If your server allows it, you may want to send shell commands to the OS to do the copy instead.
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...