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




Creating And Deleting Folders And Files


Hi to Everyone.

After creating trought http a organize number of files and folders. I'm not able to delete them, not even trought an FTP Software like Cute FTP. It replies "Could not delete xxxxx.html".




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Creating Folders
I'm a web designer working with a company that needs a website similar to myspace. I'm pretty good with php, so recreating a bootleg version of myspace doesnt seem to hard. However The one element that I am not familiar with is creating folders with PHP.

For example a user signs up, and they create a domain name "www.myspace.com/domain" well creating a separate database and all that is easy,but how to I create that folder and php files that need to go inside that folder to create there profile?

Creating Folders
im in member.php which is inside a folder called 'member'

i have a folder called 'collection' which is outside this member directory.

i want to create a folder inside the 'collection' folder based on the username, e.g,

$_SESSION['Username'] . "_images";

so that will be like: john_images folder. i want to actually check if the folder 'john_images' doesn't already exist though.

can soemone please show me how it can be done?

Creating Predefined Folders In A Bunch Of Folder
This can of course be solved with other things than php, but since I write php myself I was looking for a solution using it.

The problem is:I have folders set up like this /letter/id/ (ie. /g/132/)

What I would like to do is run a one-time operation that creates a totalt of four predefined folders in each /id/ ...
The script would have to go through all letters (ranging from a-z) and make these folders in each /id/.

Files And Folders
I need to display images on the site. Every image is being stored in its own folder. Folders are updated daily. I need to display a list folders (like FTP), and when a user clicks on a folder name, it will show them other folders inside the parent folder, or if there are no more folders inside picture files will be opened. I know how to get a list of files and open them when I am in a current folder. PHP Code:

Move Files And Folders
is there any php command for it? like copy() or rename();

Copy Files And Folders
Assuming you had a template folder and files on the webspace and you
wanted to make a exact copy/rename of it with a username and password
being the one and only difference - how would one do it ? .

(the difference being a password protected folder)

Using Files/folders To Create A DB
I'm always looking for ways to decrease the amount of time I spend adding records to my database. I was thinking about this today, and wondered if it was possible....

I want a PHP script to open a folder or folders, read the files, and make a record in the database for each file. For example: Folder 1 contains the files--4000out.jpg, 3000bcr.jpg, 4000btcf.jpg, etc...

When excuted, the script would create (in this case) three records. I only want the script to do the base work, I will add what can't be done to the records later.

Also, in the case with mp3's. I'd like the script (or a seperate one) to insert each record using the ID3v1 tag info. I'm familiar with open files and folders...but haven't come across any tutorials or scripts that do this. So...is this possible?

Copy Files And Folders From One Directory Into Another
I have files in myurl.com/myfolder

and I would like to copy all of them into

myurl.com/newfolder

I'd like to copy all of the subdirectories and files that are in
/myfolder

and I would like to be able to use a form of some sort to name the
file I want to copy, and create the folder I'd like to copy it to,
such as newfolder.

How can I use a form to create a new folder on the server?

How can I use a form to name the old folder I want to copy everything
from, then create the name of the new folder I want to copy everything
into, and then copy?

Recursive Delete All Files/folders
I want to delete all file and folder recursivly under php code, can
anyone give me commend for this.

Restrict Access To Folders/files
On a website, I will have several PDFs that I need to make available if user gives correct password or is in a given IP range. My first thought was to use .htaccess, but the host doesn't support that. they do support .htconfig and I didnt find any way of using that to resolve my needs.

If there any walk around in this situation using PHP and MySQL?

Generate New Files/Folders For A New User
I am starting to get into PHP and I was wondering if there was a way to have a PHP script that first always a guest to register (which I know there are millions out there). Second I would like after registration is complete, a PHP script will automatically copy and paste files into the users directory. For Example:

Bob just signed up on my website with the username Bob123

After he completes the registration, a Script will generate a folder called Bob123 (www.domain.com/Bob123) With files like index.htm and logo.gif in there.

Is this possible?

Security Read Write Files And Folders
when i upload files to my webspace i set permission to my files and folders. Im wondering how im unsafe if i grand a folder or file with write permissions to all/everybody. In fact I have the intelligence to understand that ones can places files to my webspace and then execute them. But I dont have the knowledge how to implement it.

How can i write to that folder and files?

Creating Dir, Copy Files And Pass Variables To 2 Files
I need to create a folder on the server weekly named by the user. To this folder copy the contents of an /Original folder. Inside the new folder edit one of the files to insert a data with a XML path generated in another application, copied (via memory) and pasted within the very first form and passed to the file in question.

<param name="FlashVars" value="xmlfile= $lanofile" />

the $lanofile is the value that I need to pass from the form to be read by this file.
I have created an form (n.php) that POST the name of the folder to a second file (creatdir.php) everything is cool until I have to edit the third file.

How can I pass the value of one of the formfileds to a second file and them read this value as a variable to be consumed as mentioned above? Or actually right whatever is on the third field to this position (not using variables).

Deleting All Files
Is it possible to delete all files in a folder using unlink() or something similar?

Deleting Files
The below should delete files from a dir older than a week. I set the $dtime to 0 to test the script but it deletes nothing. What is wrong? Code:

Deleting Files
I'm using different files to store some arrays to make administration of a very small job-logger very easy. I currently read the file, remove the element to be deleted, delete the whole file, and write the file again without that element. Is there a way to remove a single element out of that file without deleting the whole file?

Deleting Files
I'm trying to modify this script to remove files that end with %enlarged.jpg or %enlarged.gif or %enlarged.png, can someone help with the if statement, I've tried several things, of which, nothing is working: Code:

Deleting Files
I have some script that takes an album id and deletes that album and the specific photos in that album. The code does run. The problem is that an error message i set to echo appears saying error deleting photo once the page automatically refreshes. When i check the image folder the images actually have been deleted. Code:

Deleting All Files With A Certain Prefix
I'm using php 4.4.4. Given a particular directory, I want to delete
all the files that begin with the variable "$prefix". What is the
simplest way to do this?

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.

Deleting All The Files In A Directory
Using PHP 4, what are the shortest amount of lines I can write to
delete all the files in a given directory?

Deleting Files From A Server
As part of a project I want to allow users to save files to a server or delete files from a server. I have the uploader working fine, but i have no idea how i would delete the file from the server.

Attaching/deleting Files
I'm trying to create a tree where you can access files from the tree. The files will NOT be stored in the database, but on the server. I have a web forum eg, where they store the title of the message in a separate table compared with the message which is another table.

How do I store the files and show them on the tree, and how will the system know where to get the files from, if they're not in the database?

Deleting Files Onclick
I have an app that lists out the files on a server.  I have a checkbox at the end of each file.  You can check any number of files.  Then I have a link at the top that says "delete selected files."  Could someone just tell me how to write the code to delete the files in general?  I'm not asking for all the exact code, just the concept.  I assume I will be calling a php or javascript function with the "onclick" method. Code:

Error Deleting Uploaded Files
I have a configuration script which creates a directory on the server, directory used for uploading files. Everything works fine (creation of the directory, uploading) but when I try to delete an uploaded file from this directory using total commander as ftp client I get the following error: "550 Delete operation failed".

The used code is something like this:

$cursuri = "../cursuri";
@mkdir($cursuri, 0777);

Note: if I use total commander "chmod 777 cursuri" I don't get any problems.

Deleting Files In A Folder Modified Before Certain Date
I use a cache system that requires creation of files in a folder .

Now , what i need to know is how can i delete files created say 3 days ago.

So that the cache remains fresh.

The directory contains around 20,000 files , about 10,000 are generated each day (if they dont exist)

So getting info about the each file after using opendir will cause the server to slow down.

Zend Studio 3.5.2 Possibly Deleting Files?
At work I'm using Zend Studio 3.5.2 to develop PHP files on my Win2K
desktop machine. I've got Zend Studio setup with a secure FTP (SFTP)
connection to a RedHat Enterprise Linux machine. The files I'm editing
'live' on a Solaris machine and the linux machine mounts them through
NFS. I actually access the files through a symbolic link to the mount
point on the linux box. A little complicated I know, but it does work.

I've been having a random problem lately. Every once in awhile (every
couple of weeks) when I'm in Zend Studio and have a few (not all) php
files open, all the files in the directory where I'm working get
corrupted. They all get turned to a file of nothing but nulls (zeros)
and the files are exactly 512 bytes long. This concerns me because it
seems to only happen to me even though other people work on PHP files
in other directories. The difference is that I'm the only one who uses
Zend Studio regularly. I can't see how that would be a problem since
the connection to the files is through SFTP and is essentially
stateless and connectionless. Has anyone else seen this problem or have
any insight about what might be going on?

Editing And Deleting Flat Text Files
I am working on a php news script that uses text files for it's DB. I have most of it done except for the ability to edit or delete the articles in the DB.

I have only been coding for about a week now so my skills are pretty limited and I have not found any tutorials that cover this issue so if anyone could be kind enough as to show me how this is done I would be most greatful....

Creating Files
I was wondering, if/how do you create a file with PHP, Im making a "network" for my site with PHP, and ran across this problem.

Creating Files
Is there a way to create files such as config.ini thoruhg a form. so they put in all the stuff they want and press submit and then the file is created with their settings in it.

Creating Files
I am rather new to PHP and a relative newbie to Linux too.
I have a webserver at home (Apache 2.0.48 on SuSe 9.0, PHP4).
I have some scripts, one of them needs to be able to create logfiles
somewhere on my machine. It must also later be able to read from and write
to these files again.

Sofar I get a permission error. I tried chmodding 666 or 777 the directory
in which the files could reside, to no avail.
How do I set up the permissions so that my script can simply fopen a file
for writing. Or if that's not the issue, what am I doing wrong or
overlooking ?

The errors:
Warning: fopen(logfileslog1.txt): failed to open stream: Permission denied
in script1.php on line 142
Warning: fwrite(): supplied argument is not a valid stream resource in
script1.php on line 154
Warning: fclose(): supplied argument is not a valid stream resource in
script1.php on line 161
It's the first I am puzzled about, the 2nd and 3rd are a logical
consequence.

By the way, reading from and writing to a file I have previously created
myself with exactly the names I tried to get created by the script (echoed
the name, ok) is no problem at all.
So I don't think it has much to do with a safemode or open_basedir setting.
I also tried creating the scripts in the same dir the script itself resides.
Did not work either.

Creating Files
I am currently creating a file manager to add/edit/delete files and folders, etc but i was wondering if there is a function in PHP to create files such as a php file or txt file? All i want is a function that will allow you to create a file from the name you give! Is this possible? I have seen a script called Genesis but the problem is that it is Perl! and i dont have a clue about Perl!

Creating Exe From Php Files
I know for a fact that is possible but can not figure it out, how can I get my application to an exe stand alone file?

Creating And Saving Files With PHP
Hi, hope someone has some ideas !. Is there a way to use PHP and Mysql(if needed) in the following way: Lets say I used a script that when a person enters their birthday info, this script produces an onscreen report (like horoscope), how could this browser screen be saved as a file(html or other) so I could then include it into the body of an email or attach!.

Creating Csv Files From Scratch
I have a db containing customer information (ie. address, phone number, email). My client wants the ability to print mailers from the db. The idea is that the client will run searches on the db, and the search results will be dumped into a file which the client will download. The client will then give that file to their printer, to print the mailers.

The printer wants the file in csv format but I'm having trouble finding good info on creating csv files from scratch. Obviously part of the script will output the fields separated by a semi-colon, or some other delimiter, but I'm confused about how to define those fields. Does this make sense?

PHP Scripts And Creating Files
I have a PHP script that attempts to create a temporary file to be used
during processing. The script is owned by my username (bryanrme) on
the server. When the script attempts to create the temporary file, I
get a "failed to open stream: Permission denied" error. The
permissions on my directory are set to 755. When I set the permissions
to 757, the creation of the file is successful. In this case, I notice
that the script spawns a temporary file owned by a user named "99".

Is there any way to avoid this? I'd prefer not to leave my directory
set at 757, but is there any workaround for this? I checked my server
configuration and safe mode is not enabled. Any suggestions? I would
prefer that the script handle the creation, usage, and disposable of
the temporary file.

Creating Files Remotely
I'm trying to do here is write 2 files simultaneously to both the local server and a remote server on which I have write access. In the process, however, I was stuck at how to create the file initially on the remote server. I tried using touch() which works well locally to create a blank file, but I get an error:

Warning: unable to create file http://198.78.114.67/news/tech/20010718-1820.dat because No such file or directory in /home/httpd/html/makepost.php

well, I take it touch() only works locally, so, any idea guys?

Creating Text Files On The Fly
What I want to do is allow a logged in user to download a text file version of the list they are viewing on the screen. So if they are viewing the Paid list of users, there should be a button on that same page that says Download To Text File, and when clicked, the user is prompted to download a text file version of the list.

Creating .m3u Files Dynamically
Im looking at creating a playlist program for my server.  i have alist of files within my database, and i wanted to be able to place these values into a playlist file.  the problem is that i dont know how to get the database to create the playlist form its records.  ie, if i uploaded a new file to my server and into the database, then i woudl want the script to automatically grab that file ( SQL  i know), anbd the nplace it in the m3u file ( i dont know).

Coudl someone recommend a simple method to complete this?  or point me in teh righ t doirection for a tutorial?

Creating Text Files..
I want to set my access rules to 0777 so that I can delete the text file via script if I need to. I already set the folder to 0777 when I created it.. now I just need the text files. How would I set the access to 0777 when I create the file? This is what I have right now...

$text= "this is text.";
$fileName = "examplefolder1/example.txt;
$handle = fopen($fileName, 'w');
fwrite($handle, $text);
fclose($handle);

Is there some way to do it in that statement?

Strategy For Creating Files And Then Cleaning Up
I'm using PHP 4.3. There is a section of my application in which I'd
like users to be able to download a custom file. The file would be
different for each user, so I was planning on creating it on the fly
when they click "Download". However, I would like to delete the file
from the server a certain period of time after they've downloaded it.
(It's a 3 or 4K file). How can I do this?

Creating Files Using Fopen That Are Unlocked!
i'm trying to setup my website to create new webpages dynamically using
php but I am have a major problem in that whenever i create a file it
is always created locked so that it can only be read even when i
specify read and write access.

Here is a basic example of the code I am using (I am using a Mac OSX
10.3.9):

<?php

$filename = '/Users/myusername/sites/mysitefolder/newfile.php'
$mytext = 'my text'

fopen($filename, 'w+');
fwrite($filename, $mytext);
fclose($filename);

?>

When i run this program all it does is create a blank file with
read-only access. My question is what settings do I need to change that
will enable me to create writable files using PHP?

Creating Download Manager For Multiple Files
Has anyone run across some sort of download manager to be able to download multiple files at a time via http with PHP? I run a mp3 site and I would like to be able to allow people to download whole folders at a time basically the same functionality as ftp but with http. It would be kind of like the smart download thing that netscape has but cross platform compatible. Any ideas?

Creating .xls And .doc Files With Page Breaks Using PHP / MySQL
Our company currently processes a few hundred form submissions through
our site. Up till now, the contents of the form has been sent to our
customer support staff in real-time. Each submission goes to a general
e-mail box where it's printed through our mail client. A copy of the
form is also stored in a MySQL db, although it's not used that often.

I have been asked to figure out a way to stop delivering the form
submissions in real-time and migrate to the following:

Each morning, provide an Excel spreadsheet and word document (or PDF)
with a certain number of form submissions to each customer support
rep. For example, say 200 form submissions were processed the day
before. This morning, I should split those 200 among the 5 support
reps and provide each of them a certain amount (which can change
daily). Assuming each person gets 40 form submissions, each person
would need to be given an excel file and .doc document that contains
their 40 form submissions.

One of the most important things is that the .doc file needs to have
each form submission separated by a page break, so that when they
print the document each form submission is printed on a separate page.

Finally, not all of the fields from the form submission should be
given to the support rep. Maybe date and time is left off.

Creating Files From An Array Using Fopen And Fwrite
I can make a script that works fine for creating files on a single row, but I can't get it to create the content of an entire array. Code:

Deleting Files Using Unlink [function.unlink]: Permission Denied
I have a record in the db and a picture file name recorded with that record. I am writing a deletion routine which checks that file name and is supposed to delete it using unlink.

Although it reports the correct directory and file name, I received the following:

Warning: unlink(/home/pab/html/pics/test.jpg) [function.unlink]: Permission denied

I checked my permissions and the file is set at my user name and 666.

Does anyone know why this won't work or maybe another way to delete the file?

Batch File Deleting And Folder Deleting
I have a folder in my web site where I used php to create and copy in files. but now I can't delete them easily. The only way I know how that is possible is through php. I get an error the following ftp error:

550 th: Permission denied
I had the chmod() set to 0777 on every file and folder. But I still seem to loss control over the files when I try and do things with them through other means.

I think it is because the user I use to access the files via ftp a diffrent user. So I tryed to add a function with chown() for the new files I was posting and uploading. It didn't work on those new files. so it looks like the only thing I can do is use the unlink() function which deletes the files fine.

The only problem is now I have something like 100 sub directories all with files in them. I need to figure out a way to batch delete them. I can't find a script that goes through and finds all file contents including all sub directories and unlink those things.

I found some that will use a for loop to list out the contents of a folder but it is just files. No sub directories. Any body got any ideas on which functions I should use or know where a script is that I can base mine off of.

I am not sure how to approach this since what I tryed with chown and chmod has failed thus far. I currently have no code and am starting from scratch on this batch flushing of my directory.

Uploading Folders
Is it possible to upload entire directories from a form in such a way
that a user can browse to the folder on their local machine and select
it for uploading or synchronization? I am using php5.

Reading Folders
If I had several folders full of images, how can I get PHP to open the
folder, read the image names and save the image names (inc extension) to a
MySQL database?

What I am trying to do is create an image gallery using PHP/MySQL, so that
everytime i take a load of pics, all I would have to do is get PHP to read
the contents of the folder and add the filenames to a MySQL database rather
than having to manually input the names into the database


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