sniperscope Posted January 14, 2009 Share Posted January 14, 2009 hi, i have little problem with ftp below script creates folder with valid ownership. $file_name = $_POST['name']; $path = "/public_html/img/stuff/" .$file_name; $conn = ftp_connect("ftp.co.jp") or die("Could not connect"); ftp_login($conn,"japan","123456"); ftp_mkdir($conn, $path); ftp_close($conn); but when try to upload and/or delete a file i got error such as file not found. here is upload file code for upload.php. $name = $_POST['name']; // Configuration - File type Options $allowed_filetypes = array('.jpg','.gif','.png'); $max_filesize = 524288; // Maximum filesize in BYTES (currently 0.5MB). $upload_path = '../img/stuff/'.$name; // The place the files will be uploaded to (currently a 'files' directory). $upload_path = $upload_path.'/'; $filename = $_FILES['userfile']['name']; // Get the name of the file (including file extension). $ext = substr($filename, strpos($filename,'.'), strlen($filename)-1); // Get the extension from the filename. if(filesize($_FILES['userfile']['tmp_name']) > $max_filesize) die('The file you attempted to upload is too large.'); if(move_uploaded_file($_FILES['userfile']['tmp_name'],$upload_path . $filename)){ header ('location: index.php.php'); } else { echo 'There was an error during the file upload. Please try again.'; } and here is the folder deletion code for delete_folder.php. $name = $_POST['name']; if(!file_exists($path = ("../img/stuff/".$name))){ echo "File Not Found"; } else { $path = ("../img/stuff/".$name); $origipath = $path; $handler = opendir($path); while (true) { $item = readdir($handler); if ($item == "." or $item == "..") { continue; } elseif (gettype($item) == "boolean") { closedir($handler); if (!@rmdir($path)) { return false; } if ($path == $origipath) { break; } $path = substr($path, 0, strrpos($path, "/")); $handler = opendir($path); } elseif (is_dir($path."/".$item)) { closedir($handler); $path = $path."/".$item; $handler = opendir($path); } else { unlink($path."/".$item); } } return true; //echo "Folder was Deleted succesfully"; } delete_folder.php seems work good but when i check the folder via FTP program i see the folder and whole files still there. i am totally desperate. Where and what am i doing wrong ? Link to comment https://forums.phpfreaks.com/topic/140790-ftp-upload-and-delete-problem/ Share on other sites More sharing options...
sniperscope Posted January 14, 2009 Author Share Posted January 14, 2009 no body knows ? Guys i stuck there and need help. I tried almost all ftp_ functions but seems i doning something wrong. ??? Link to comment https://forums.phpfreaks.com/topic/140790-ftp-upload-and-delete-problem/#findComment-736965 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.