Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    PHP




Delete Folder FTP


I am trying to delete a folder and all of its contents (folders, files) through ftp. I am trying to modify a script for deleting it locally. I don't get any errors with this, but nothing happens. Can someone point me in the right direction? Code:




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
How To Delete An Undeletable Folder!
I run PHP5 and was testing a script to allow users sampling a demo script
But to keep security high asides the usuals I create a new folder and a new set of scripts per each required demo with a folder extension created by a rand function. So first the folder is created and a set of tpl are copied in the new folder and written on.

To make a story short:
While testing on the production server I found some bugs and fixed them but the first trial attempt created a folder with a set of files that weight exactly as the tpl copied from and do have a correct PHP extension but refuses to be deleted or renamed or schmod etc... via FTP

Now that I am bugless I can indeed do whatever with then newly created folders and files but still cannot delete my first test.

When I try to del it it goes away but if I refresh it’s back there!

Delete Folder And Its Contents
is there any way of deleteing a folder and all of its contents using PHP?

Delete Image From Folder
I have some php scripts to upload images and delete it. But if I delete the image I only delete the image's data in the database, and the image still remains in the folder. My question is, how can I remove the image from the image folder?

Delete Ftp-folder Created Via Php Installation?
how do I delete a folder at my ftp-server, that was automatically
created through a installation script? I dont have the permission to
delete that folder :-(

I have already found the following script, but I dont know where exactly
do I need to execute it:

---------------------------------------------------
<?php
function delete($file) {
chmod($file,0777);
if (is_dir($file)) {
$handle = opendir($file);
while($filename = readdir($handle)) {
if ($filename != "." && $filename != "..") {
delete($file."/".$filename);
}
}
closedir($handle);
rmdir($file);
} else {
unlink($file);
}
}

delete("folderrname");
-------------------------------------------------

....whereas foldername at the end is the folder to be deleted.
?>

Drag Files From One Folder To Another Folder (copy) .. Possible?
Is it possible to write codings PHP or Javascript.. GUI representation
of File handling (ie. Drag files from one folder to another folder (copy)
like our windows).. pls give me some reference codings like this..

Remove From $name (folder)/(folder)/[x]/ <-- If Exists To Just Get [x].
I'll be quite honest. I don't have the faintest idea
how to do this, while I can do other php without a problem. Once I
know how to go about it I'll be okay.
It's two things I think?
1. see if there's a trailing slash and delete it.
2. Remove the preceding path to /x, the folders and slashes, and
delete them.
and then I have x.

X by the way is the final folder in a website and this grabs it for
me.

<?
$name = $REQUEST_URI;
?>

How To Get Folder Name Out Of
An easy one for somebody, but I have not got my head round it yet. I need to get the folder name out of a URL ie:

/support/desktop/documents/general/fa95e9e698c76fdc606f3b94fe89b48b/17_Import_data_en.pdf

$folder = fa95e9e698c76fdc606f3b94fe89b48b;

PHP 5.2 Doesn't Have Ext Folder?
I just downloaded and installed php v5.2, Apache 2.2 and mysql 5.0.27. I'm having the same problems as many regarding the "undefined function" error and am trying to work through it, but I'm noticing (via many of these troubleshooting tutorials) that people are talking about an "extensions" folder and a php-recommended.ini file and the such, and I notice that I don't have either in my installation of 5.2.

Did I download the "preferred" installation package? The one I downloaded is called php-5.2.0-win32-installer.msi.

I'm coming from a php 4.4.2 apache v1.3.31 and mysql v4.0.20a - all of which was lost during a major crash so I have nothing to compare these 5.2 files against.

If I've downloaded a "non-preferred" installer, could someone tell me which one I should install to get everything working properly -- or at the least to have a complete package.

Folder Name As A GET?
I currently have a website and would like to be able to give my members
an alias to access their profile. At the moment, people have to go to
something like www.domain.com/viewmember.php?id=3456, which isn't
practical unless it's through clicking links.

I'd like to be able to give my members the ability to use something
like www.domain.com/myname, which would then forward to the correct
page. The problem I can see is that the server thinks myname is
actually a folder and returns a 404 error.

Does anyone know of a way to do this?

Check For Folder
how would i check if there's at least one folder in the current folder? the current folder is $dir/$f/

this is what i have, but i know its wrong

$fillle = "$dir/$f/";
if (file_exists($fillle)) {$Q="true";} else{$Q="false";}

Folder Retrieval
I have managed to retrieve a list of pdfs that are in a folder and displayed them with a link to a new window:

<?php
//RETRIEVES FOLDERS CONTENTS
$dir = "/var/www/html/bbcl/building/projects/pdfs";
$folder = "/bbcl/building/projects/pdfs/";
$handle = opendir($dir);
while ($file = readdir($handle)) {
if ($file != "." && $file != "..") {
echo "<a href="$folder$file" target=new>$file</a><br>";
}
}
?>
But it also display's the name of folders that live there, anyway of specifing what file extensions to appear in the list?

Rename A Folder
Is there an easy way to rename a folder? A function I am missing?

Could You Tell Me How To Attach My Folder
Could you tell me how to attach my folder. It will only let me send one at a time.

Renaming A Folder
is there any way to rename a folder using PHP?

Getting And Using Contents In A Folder
I want to make a photogallery/slideshow with PHP...

The 'gallery/slideshow' would show up inside a new window.
basically, I just want links with possibility to go:

- forward
- back
- to the very beginning
- to the very end
- away (close the window)

Can I use PHP to determine the contents of the folder with the pictures and then use variables to determine which photo to show, and what URL's should be generates for the arrows? So each folder with a series of photographs would have one PHP file and the pictures themselves in them (it's not a problem to rename them).

Should be simple enough, but I'm just starting out with PHP, and I'd like to have something working as soon as possible... the website I'm working on is about to launch soon (my first 'commercial' web project :) ), and this is about the only thing left that I still have to sort out how to do...

Size Of Folder
how i get the size in k of a certain folder on mysite, i know i've done this before but can't think of what to look under at php.net.

Current Folder
Does anyone know easy way to find out the current folder where the script is? I tried to this but it doesn´t work in my Linux web-server, but it works in NT-desktop.

$dir1 = getenv(PATH_INFO);
$last = strrpos($dir1, "/");
$dir2 = substr ($dir1,0, $last);
$name = strrpos($dir2, "/");
$folder = substr($dir2,$name+1,20);

Folder Permission
I have a problem when i create a folder using the following php code:

<?php mkdir ("foltest/bleh", 0777); ?>

The problem is that the folder "bleh" doesn't have the 777 permission like I wish it did, but it has 755 instead. Is there something wrong with my code, or could this be caused by my host?

Folder Browser
I'm looking for some sort of php folder browser - basically if i have the following folders;

index
index/welcome
help
help/email
help/web
docs

in one pull down will display the folders index, help, and docs - where as menu 2 will display the folders that lie in index, help or docs.

The Root Folder
I've a web site in the address http://mySite.com
in the root, I've a file index.html

I've some subfiolders insid root/sub1/sub2

I like to add an html file (or php) index.html that call the index.html of
the root (in order to protect)
Now I've created 2 different index.html because I use relative path to
design the root (../index.html and ../../index.html)

I like to have the same file in all folders,but I don't know how to call the
root folder.

Folder Permissions
My trouble might be simple, but I'm quite new to php, and, perhaps I'm even
more simple.
It's that I had to chmod 777 two folders to get my scripts do what I wanted
them to do, and I don't like it.
I have a script running on my ISP's unix-apache -server. It is to read
string from a form, and create a text-file in a subfolder 'txt' from it.
The essential parts of the script is here:

$fnam=$HTTP_POST_VARS[filename];
$handle =fopen("txt/".$fnam, "w");
$teksti=$HTTP_POST_VARS[tekstikentta];
touch('txt/'.$fnam);
fwrite($handle,$teksti);
fclose($handle);

Can't be simpler.
This script didn't work until I did a chmod777 for both folders, the one
where this script is, and the 't' subfolder. Is there a way to get around
this?

Folder Loop
i have a folder called "profile_images" how do I loop through the images in this folder, and echo each filename guys?

Getting Contents Of Folder
I've made half of the code for a little "hosting" site for a few of the members of my site. Their files are uploaded to /login/<username>/

I'm now stuck as to how to show the contents of the folder in a page. I think the use of fopen() is needed, however the php website is a little confusing.

Getting The Size Of A Folder
All Ive been trying to do is make a short php script (embedded in the html, no separate file) that simply displays how much space, in megabytes, the contents of a certain folder is taking and use an echo command to display it. I've tried the filesize command and it always gives me 4,096 regardless of the contents. I assume this is because PHP is taking the size of the actual folder. I've tried disk_total_space but this displays a number that is completely off.

How Do I Add A New File To A Folder?
Say I want to add a file named 123.php to the folder /xxxx/ How would I do that using php and a form? Is there a function or a tutorial?

Deleting Folder
is there anyway of deleteing a folder and deleting all of its contents with it?
i know that with rm_dir needs to folder to be emptied

How Much Space A Folder Is Taken Up
How is everyone? Well I was just wondering if somebody got teach me how to make a PHP Script which tells you how much space a folder is taken up? Example: I have a folder called ./files, I want a script which will tell me howmuch space its taken up .

Check If A Folder Contains Anything
what do I use to check if a directory contains anything.

For example how do I check if there is anything in this? (Which in english is something like news/download/may2007/document1.doc

UPLOADS_PATH.'/news/download/'.$oDownload->download_path.'/'.$oDownload->download

Copy Folder?
I want to copy a folder, subfolder, files, and subfiles.  I don't care about attributes. I thought about making the folder a zip, and then using extract but that was confusing and took too long on the server.

so what do I do?  Is there a script that will parse the dir and COPY all the files?

Folder Permission 777
I need to upload pictures for a photo gallery but in order to work the upload, the folder's permissions must be 777. ( or am I wrong?). chmod 777 as read thousand times is not secure so what can I do?

Check if the folder and change the permissions before and after the upload? Is this secure?

INCLUDE'ing To A Different Folder..?
I've got a file structure

-www (containing normal site files)
-www/inc (containing includes like db.php, session.php etc)
-www/accounts (containing an area for customer login)

I'm working on www/accounts/signup.php and am trying to use the following code:

<?php
include "/inc/session.php";
?>
...so that certain session elements can be set. however, I'm getting an error

Warning: include(/inc/session.php) [function.include]: failed to open stream: No such file or directory in E:XAMPPxampphtdocsmysiteaccountssignup.php on line 3 (I'm using Xampp as a testing server as well as my live server)

 - I've tried various combo's of paths to the sessions file, but the server is not allowing a proper include to it.

Upload Folder
I have this code:

$uploaddir = dirname($_SERVER['SCRIPT_FILENAME']) ."/Images/";

and it uploads the image to /admin/images/ as the page i'm running it from is in the admin directory.

I've tried just using the http:// and it doesn't like it. Could someone please tell me how i can make it upload the image to /images/ instead of within the admin folder.

Getting All The Sub Directories In A Folder.
I want to return all the subfolders in a given folder any idea? I thought glob can only do files.

Delete From $var
Is it not possilbe to have a variable for the table name in a delete statement (mysql database). inside an if this button is hit statement I have:

$sql = "delete from $type where id_num='$number'";
mysql_query($sql);
echo "$sql";

when it echos $sql it doesnt have the $type var where the table name should be, it just leaves that blank.

Delete A Row
This should be simple enough but for some reason it's not working. The $name is a number which is being posted across when the user clicks submit. I want the PHP to then access the Database with this number and use it to delete the staff ID (which is a PK).

With this code I get the error:

Warning: ociparse(): supplied argument is not a valid OCI8-Connection resource in /homedir/ilex-s01/jmsuther/public_html/DeleteStaff.php on line 16

Warning: ociexecute(): supplied argument is not a valid OCI8-Statement resource in /homedir/ilex-s01/jmsuther/public_html/DeleteStaff.php on line 17
;

The code is:

$name = $_POST["staffnodelete"];
IF ($staffnodelete=="" )
{print "You selected $name - for deletion ";}

putenv("TNS_ADMIN=/u1/oracle/Products/shu10g/network/admin");
$con = OCILogon("username","password","10g");

$query = "DELETE FROM staff WHERE staffno = $name";
$query = $query_post [$name];
$stmt = ociparse($conn, $query);
ociexecute ($stmt);

How To Protect A File Or Folder?
I want to protect my URL
How to realize the following function?
Users click on the URL, a login htm page appears. Users enter username, password and click on the submit button. PHP file consults mySQL to get username, password and registration date. If user account is valid, user may download this software.

How To Get The Files Names From The Folder Using PHP ..
How to get the files names from the folder using PHP .. is there any
specific command. If yes let me know that..

Folder/File Perms...
I made a PHP script that creates a new folder (say "Folder 1") and then copies a file from the parent folder (call the file "index.php") into the new folder; so we get Folder 1/index.php

Now, how can I set the ownership of this file and folder, automatically via the PHP script, to me (the server user), not httpd?

Restrict PHP Usage From A Folder
Here's the context: We have a server and have been hosting our own websites for a while. But now, a customer wants to have FTP access in order to manage his static, non-PHP website. I found a solution that seems to work and would like to know if it is safe enough to be used.

I added:
<Location />
ForceType text/html
</Location>

To hpptd.conf file in the vhost entry of my customer's website. It seems to work fine, as all .php files are not parsed by php anymore.

It is not easy nor possible to change the global configs of the httpd.conf and not possible also to install a separate apache server.

So, do you believe that this is an appropriate solution?

Paging Of Folder Files
i have a form which has a select button when user clicks it a popup opens which shows all images in abc folder
 
when user clicks on any image the window closes and the name of that image is entered in the text box in parent form, now its working fine uptill here but if user refresh the popup window then it disconnects from parent window so my code that fills the textbox in the parent form and closes the popup window does not work anymore im using it like parent.document.form.texthox.value=abc since popup window is refreshed it does not work as child any more and this code does not work.

Files And Folder Copying
I am trying to write a function to copy an existing folder and folder
structure but am already stuck.

What I want to do is the following:

Copy a default folder (default_folder) and all sub folders within it (down
to a possible 4 levels)
eg default folder
->subfolder1
->subfolder2
->sub subfolder1
->sub sub folder 2

I have a form where the user can enter the name of the new folder and an
option to confirm if they want to copy the files also located within the
default folder.
If the checkbox is not checked then copy just the folder structure only

Can this be acheived in one function or will it be based on 2 where a set of
empty folders are created and where the folders and files are copied over

PHP 4.3.8 On WinXP - No Sapi Folder??
I am so confused right now. I installed 4.3.8 on my computer and am reading
the install notes for apache. It refers to all these dlls and the sapi, but
under c:php, I don't see any of that stuff! What is going on here?

What Is The Max PDF Files Allowed In A Folder?
Not sure where to put this question? I am building a book archives database with a front-end for some librarians. They want to upload book cover images onto the server (probably Win-NT). There are approximately 80000 records that will have the book cover images stored in a PDF document for each. Can I upload every PDF to the same folder? Is there some kind of limit for a folder?

Deleting Files From A Folder...
I have a folder with many pictures in it.
All have the name like: HHMMDDMMYYYY.jpg

H-hour
M-minute
D-day
M-month
Y-year

Now I want to delete all pictures which are older than now()-7days.
How Can I do it? In SQL would be no prob but with file deleting is problem.

Opening Files In The Same Folder..
I have a php file (1.php) that needs to open another php file (2.php) and parse it's output. 2.php gets it's data from an xml file and formats it in a pretty screen style. So what I need is something like: $fp = fopen ("2.php?file=file.xml","r"); but that wont work because there is no file called &#392;.php?file=file.xml' so how's it done?

Upload To Specific Folder
I am working in a directory:

/www/domain/
and made the directory
/www/domain/images/

What I need is for people to be able to upload images to this folder from a form on upload.php They should click browse and select their file to upload then press the "Upload" button. On the next page I want to display the .jpg or .gif that they uploaded.

What is the coding for uploading that should go into the first upload.php script and the coding for the upload_result.php script. I think that the result could be:

echo "<img src="images/$file">"; where $file = the image they uploaded. But I cannot seem to figure out what the first code should be.

Root Of Folder App Files
While I know putting a app into a folder was chiseled out of fine
scottish granite and carried upto the top of ben nevis by php newbies
many years ago - I dont think a folder is the best way to do it .

The fact a script is in a folder means certain instant problems if you
want to do certain things with .

Assuming a script doesnt have index.php and all the script files have a
filename prefix like phpgb_ then theres no chance of them clashing with
anything else and theres no real reason to continue using a folder for
the main script files .

While the script will have a app folder for various things - does it
make any sense not to use the root because of a single solitary file
called index.php .

phpgb_index.php is what I use and the method hasnt brought up a single
problem of any shape or description .

Gas lighting was once what everybody thought was the best way of doing
it until that darn new fangled electricity came along .

1 - 2 Millions Files In One Folder?
I have to store over a million files, 10 - 15 kb each, in one folder.
The files are created by my php script, sometimes the old files are
deleted and new ones are written.
So, basically on every connection my script reads/deletes/ writes files
from/to that folder.
Right now i have only around 300 000 files in that folder, and it feels
like its getting slower for that script to work. It does work at the
moment, but i am not sure what will happen when there is over a million
files there...
Are there any limits of files that can be stored in a folder?
Would it be better for me to use mysql? I am not sure how mysql will
cope with millions of writes/reads

Html Code From Folder
How can I write a php code that when it is include in a html page it
create a menu link automatically, reading from a main folder its
subfolder and html files?


Copyright © 2005-08 www.BigResource.com, All rights reserved