Forum Moderators: coopster
I can see the file on the server in my ftp program but if I try and CHMOD or delete it, it tells me the file does not exist.
[edited by: Pico_Train at 6:12 am (utc) on Sep 3, 2011]
if(!empty($_FILES))
{
{
$title = $db->escape($_POST['title']);
//testing
//$fullpath = "../files/music/".$profile_id."/";
//live
$fullpath = "../../files/music/".$profile_id."/";
//echo $fullpath;exit();
$previewpath = $_SERVER['DOCUMENT_ROOT']."/files/".$profile_id."/";
if(!file_exists($fullpath))
{
//testing
//mkdir("../files/music/".$profile_id."/");
//live
mkdir("../../files/music/".$profile_id."/");
}else{
}
if(!file_exists($previewpath))
{
mkdir($_SERVER['DOCUMENT_ROOT']."/files/".$profile_id."/");
}else{
}
$extlimit = "yes"; //Limit allowed extensions? (no for all extensions allowed)
//List of allowed extensions if extlimit = yes
$limitedext = array(".mp3");
//preview details
$preview_type = $_FILES['preview']['type'];
$preview_name = $_FILES['preview']['name'];
$preview_size = $_FILES['preview']['size'];
$preview_tmp = $_FILES['preview']['tmp_name'];
//fullsong file details
$fullsong_type = $_FILES['full_song']['type'];
$fullsong_name = $_FILES['full_song']['name'];
$fullsong_size = $_FILES['full_song']['size'];
$fullsong_tmp = $_FILES['full_song']['tmp_name'];
//check if you have selected a file.
/*if(!is_uploaded_file($preview_tmp) || !is_uploaded_file($fullsong_tmp)){
//echo "Error: Please select a file to upload!. <br>--<a href=\"$_SERVER[PHP_SELF]\">back</a>";
exit(); //exit the script and don't process the rest of it!
}*/
//check the file's extension
$ext_preview = strrchr($preview_name,'.');
$ext_preview = strtolower($ext_preview);
$ext_full = strrchr($fullsong_name,'.');
$ext_full = strtolower($fullsong_name);
//uh-oh! the file extension is not allowed!
/*if (($extlimit == "yes") && (!in_array($ext_preview,$limitedext)) && (!in_array($ext_full,$limitedext))) {
$message = "These types of files cannot be uploaded. Please upload an MP3 file. <br>--<a href=\"$_SERVER[PHP_SELF]\">back</a>";
//echo $message; exit();
}*/
//so, whats the file's extension?
$getPreviewExt = explode ('.', $preview_name);
$file_preview_ext = strtolower($getPreviewExt[count($getPreviewExt)-1]);
$getFullExt = explode ('.', $fullsong_name);
$file_full_ext = strtolower($getFullExt[count($getFullExt)-1]);
//create a random file name
//$next_id = $model->getnextMusicId();
$rand_preview_name = $title."_preview.".$file_preview_ext;
$rand_full_name= $title.".".$file_full_ext;
$file_preview_exists = "$previewpath$rand_preview_name";
$file_full_exists = "$fullpath$rand_full_name";
//chmod("../../files/music/".$profile_id."/".$rand_full_name, 755);
//chmod($_SERVER['DOCUMENT_ROOT']."/files/".$profile_id."/".$rand_preview_name, 755);
move_uploaded_file($_FILES['preview']['tmp_name'], "$previewpath$rand_preview_name ");
move_uploaded_file($_FILES['full_song']['tmp_name'], "$fullpath$rand_full_name");
if (file_exists($file_full_exists) && file_exists($file_preview_exists))
{
/*$message = "<b>The file ". basename( $_FILES['preview']['name']).
" and ". basename( $_FILES['full_song']['name']).
" have been uploaded to your profile.</b><br><br>";*/
} else{
/*$message = "<b>The files ". basename( $_FILES['preview']['name']).
" and ". basename( $_FILES['full_song']['name']).
" were not uploaded. Please try again.</b><br><br>";*/
}
$uploaded = $ins->insertMusic($_POST, $fullsong_type, $preview_type,$rand_full_name, $rand_preview_name);}}}
The files uploaded with the script and the files uploaded via FTP have the same permissions - 644 1 works, the other doesn't.