Jump to content

Error with upload 0byte file.


herghost

Recommended Posts

Hi Guys,

 

What I am doing is making a backup of a folder by zipping it on a server which is outside of web root, downloading a local copy to a web accessible place and then uploading the zip file back to the non web folder. I am using phpseclib's sftp to achieve this.

 

The error I have is that when the file is uploaded to the non web area, the file is 0 bytes and cannot be used, the copy stored on the web accesible area is fine?

 

The code I am using:

 

<?php
if(isset($_GET['backup']))
{

	$worldname = $_GET['backup']; //checks to see if upload

	if(!is_dir("backups")) //create backup directory if not exist
	{
		mkdir("backups", 0777);
	}

	mkdir("backups/".$worldname, 0777); //make filename directory


	$main_dest = "backups/".$worldname.""; //set backup destination
	$delpath = "backups/"; //path which will be deleted later

	$sftp = new Net_SFTP($host);
	$sftp->login($root_user, $root_pass);  //login to sftp
	$get = "/root/minecraft/".$worldname."/"; //get correct directory for backup

	get_folder($sftp, $get, $main_dest ); //execute command

	Zip('backups/'.$worldname.'','backups/'.$worldname.''.date("dmy-H:i").'.zip'); //make zip of folder



	$sftp->put('/root/minecraft/backups/'.$worldname.''.date("dmy-H:i").'.zip','backups/'.$worldname.' '.date("dmy-H:i").'.zip',NET_SFTP_LOCAL_FILE); //put zip file from web folder to root/backup folder
	rrmdir($delpath); //delete old folder (function below)
	//unlink('backups/'.$worldname.''.date("dmy-H:i").'.zip'); deletes web copy


	header('Location: index.php');

}

The line which is causing the issue is:

 

$sftp->put('/root/minecraft/backups/'.$worldname.''.date("dmy-H:i").'.zip','backups/'.$worldname.' '.date("dmy-H:i").'.zip',NET_SFTP_LOCAL_FILE);

 

The function is basically $remotefile, $data, $mode

 

Can anyone take a guess at what is causing the issue? PHP max upload size is 200mb, the files are around 5mb, the timeout is 360 seconds?

 

Cheers

 

Dave[/code]

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.