PHP Classes

how to add or change folder and download the file

Recommend this page to a friend!

      AJAX Web files browser  >  All threads  >  how to add or change folder and...  >  (Un) Subscribe thread alerts  
Subject:how to add or change folder and...
Summary:file & folder
Messages:2
Author:edward sinaga
Date:2012-01-04 08:39:07
Update:2012-01-05 13:28:42
 

  1. how to add or change folder and...   Reply   Report abuse  
Picture of edward sinaga edward sinaga - 2012-01-04 08:39:07
How can i add a folder..?
how can i change to different folder..?
how can i download a file..?
is it possible to make it like tree browser..?

Best Regards,
Edward

  2. Re: how to add or change folder and...   Reply   Report abuse  
Picture of Horghidan Diana Horghidan Diana - 2012-01-05 13:28:42 - In reply to message 1 from edward sinaga
Hello!

This is something I have done:

function remove_bad_characters($text){
$first = array("\\", "/", ":", ";", "~", "<br>", "(", ")", "\"", "#", "*", "$", "@", "%", "[", "]", "{", "}", "<", ">", "`", "'", ",", " ");
$last = array("_", "_", "_", "_", "_", "_", "", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "", "_", "_");
$text_rewrite = str_replace($first, $last, $text);
return $text_rewrite;
}

if ( !is_dir($path)) {
mkdir($path,0777,true);
}
if ( is_dir($path)) {
chmod($path,0777);
if(is_array($_FILES) && sizeof($_FILES) > 0){
$filename= $_FILES['file_name']['name'];
$filename = remove_bad_characters($filename);
if (@move_uploaded_file($_FILES['file_name']['tmp_name'], $path.$filename)){
//do something
}else{
switch ($_FILES['file_name']['error']){
case 1:
print '<p> The file is bigger than this PHP installation allows</p>';
break;
case 2:
print '<p> The file is bigger than this form allows</p>';
break;
case 3:
print '<p> Only part of the file was uploaded</p>';
break;
case 4:
print '<p> No file was uploaded</p>';
break;
}
}
}else{
print '<p> Invalid file</p>';
break;
}
}
}


//$path - is the path where to upload the file;if the folders does not exist then are created



Sorry about the previous messages, but I am used to use tab to arrange the code.

Best regards