Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums

Go Back   Code Forums > Application and Web Development > PHP

Reply
 
LinkBack Thread Tools Display Modes
Old 06-28-2006, 07:01 AM   #1 (permalink)
markster
Code Monkey
 
markster's Avatar
 
Join Date: Jun 2006
Posts: 65
markster is on a distinguished road
Question How do I check if a file exists/delete a file?

How can I check if a file exists in a certain folder, I had an idea, but I think there might be another way. This was my idea:

PHP Code:
<?php
$i 
fopen("file.txt","r");
$data fread($i1000);
$close fclose($i);
if (
$data=="") {
//Some command to delete file.txt
}
else {
$name $data;
}
?>
But I don't know how to delete a file. Or is there an easy way to check if file exists?
markster is offline   Reply With Quote
Old 06-28-2006, 07:07 AM   #2 (permalink)
markster
Code Monkey
 
markster's Avatar
 
Join Date: Jun 2006
Posts: 65
markster is on a distinguished road
Nevermind, I've just found out about the

PHP Code:
file_exists("file.txt"
command.

If any modeator feels like locking this thread, go ahead ;-)
markster is offline   Reply With Quote
Old 06-28-2006, 07:30 AM   #3 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,446
sde is on a distinguished road
no need to lock threads .. discussion is good

nice how they name functions in php huh.
__________________
Mike
sde is offline   Reply With Quote
Old 06-28-2006, 10:12 AM   #4 (permalink)
Redline
PHP Student
 
Join Date: Oct 2004
Location: Forest Grove, OR
Posts: 150
Redline is on a distinguished road
Send a message via AIM to Redline Send a message via MSN to Redline
By the way, to delete a file, use the function unlink(filename.ext);
__________________
Current Project
Redline is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Log4j created file not able to delete while testing my application?? j.gohel Java 12 04-07-2006 10:52 AM
form file field check metazai PHP 7 08-18-2005 06:59 PM
javascript: check if file input is undefined sde HTML, XML, Javascript, AJAX 3 03-28-2005 08:15 AM


All times are GMT -8. The time now is 10:54 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting