Problem using Uploadify along with ftp_put

Hi friends

I was going to use Uploadify for videos. While the code worked nicely for move_uploaded_file, I am having a problem with ftp_put. Below is the code of Uploadify.php, for those who know it.

Thanks for any help. I have tried to echo individual variables of ftp_put to see if there is a problem there. I don’t have one there, all the variables are printing properly.

Thanks again if anyone can solve this.

require_once '../../include/sql.php';
Copyright (c) 2012 Reactive Apps, Ronnie Garcia
Released under the MIT License <> 
function makeName($string){
  $str = strtr($string,'àáâãäçèéêëìíîïñòóôõöùúûüýÿÀÁÂÃÄÇÈÉÊËÌÍÎÏÑÒÓÔÕÖÙÚÛÜÝ','aaaaaceeeeiiiinooooouuuuyyAAAAACEEEEIIIINOOOOOUUUUY');
  return preg_replace('/\s+/', '', $str);

$verifyToken = md5('unique_salt' . $_POST['timestamp']);

//if (!empty($_FILES) && $_POST['token'] == $verifyToken) {
if (!empty($_FILES)) {
	$tempFile = $_FILES['Filedata']['tmp_name'];
	$targetFile = IMG_LOC . $_POST['timestamp'].'-'.makeName($_FILES['Filedata']['name']);
	// Validate the file type
	$fileTypes = array('mp4'); // File extensions
	$fileParts = pathinfo($_FILES['Filedata']['name']);
	if (!in_array($fileParts['extension'],$fileTypes)) {
		echo $val;
	} else {
		if ($conn_id = ftp_connect(SERVER)) {
			if ($login_result = ftp_login($conn_id, FTP_LOGIN, FTP_PASSWORD)) {
				ftp_pasv($conn_id, true);
				if($ftpPut = ftp_put($conn_id, $targetFile, $tempFile, FTP_BINARY)) {
				} else {
					$val = UPLOAD_FAILED; // This is what I am getting
			} else {
				$val = LOGIN_FAILED;
		} else {
		echo $val;
} else {
	$val =  NULL; 
	echo $val;

You’re 100% certain that the below line is being evaluated?

if($ftpPut = ftp_put($conn_id, $targetFile, $tempFile, FTP_BINARY)) {

Have you checked the apache error log for any possible indication of what might be going on?

What are the values of $targetFile and $tempFile when the previous line is evaluated?

Was PHP configured with the --enable-ftp option?

Thanks for your reply oddz.

$targetFile = /var/www/
$temFile = /tmp/phpsWohX3

The above is correct since with the same variables move_uploaded_file was working, that I have quoted out.

I tried to find the error log, but I don’t see that in the server. Its a custom made one, and may be they have intentionally stopped error log to be shown in the available folders of ftp ?

For --enable-ftp, how can I know if my server is configured for that, any idea ? I looked at phpinfo, don’t see that Configure Command block where --enable-ftp would have been noted. However, there is a seperate block telling FTP support is enabled.

I would begin debugging this through a separate script with bare essentials of establishing an ftp connection and placing a file on the server.

Found the solution. The target destination need to be a relative path. I was using an absolute path and hence the problem :slight_smile:

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.