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.
<?php
require_once '../../include/sql.php';
/*
Uploadify
Copyright (c) 2012 Reactive Apps, Ronnie Garcia
Released under the MIT License <http://www.opensource.org/licenses/mit-license.php>
*/
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)) {
$val = WRONG_EXTENSION.
echo $val;
} else {
//move_uploaded_file($tempFile,$targetFile);
set_time_limit(0);
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)) {
$val = UPLOAD_SUCCESSFUL;
} else {
$val = UPLOAD_FAILED; // This is what I am getting
}
} else {
$val = LOGIN_FAILED;
}
} else {
$val = CONNECTION_FAILED;
}
ftp_close($conn_id);
echo $val;
}
} else {
$val = NULL;
echo $val;
}
?>