Microsoft Windows Support

  • Subscribe to our RSS feed.
  • Twitter
  • StumbleUpon
  • Reddit
  • Facebook
  • Digg

Friday, 4 January 2013

How To Creating and Deleting Files Through Code in PHP

Posted on 08:36 by Unknown
We can create or delete files through code using the touch() function to create them, and the unlink() function to delete them. Both functions are part of the Filesystem family of functions. You can check to see whether a file exists before you attempt either function, and you can also check to see if the file exists to verify that touch created it for you if it was not already there.

touch() will create the file if it does not exist already.

unlink() will delete any type of file from your server.

Here is an example showing how to use the touch() function to create a file:
Learn HTML
<?php  // you can create any extension type file(html, php, xml, etc...)
$file_x = "my_file.txt"; 
$createFile = touch($file_x);

if (
file_exists($file_x)) {
    echo 
"The file has been created";
} else {
    echo 
"The file has not been created";
}
?>

Develop PHP browser display window
The file has been created


Here is an example showing how to use the unlink() function to delete a file:
Learn HTML
<?php  // you can delete any extension type file(html, php, jpg, gif, flv, swf, etc...)
$file_x = "my_file.txt";

if (
file_exists($file_x)) {

    
unlink($file_x); // delete it here only if it exists
    echo "The file has been deleted";

} else {
    echo 
"The file was not found and could not be deleted";
}
?>

Develop PHP browser display window
The file has been deleted

Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Posted in | No comments
Newer Post Older Post Home

0 comments:

Post a Comment

Subscribe to: Post Comments (Atom)

Popular Posts

  • how linux is built
  • Samsung Electronics has bought Boxee
    Samsung Electronics has confirmed its purchase of Boxee on Wednesday for its  smart TVs .  Samsung plans to use this acquisition as a way to...
  • Another Microsoft Guru Steps Down
    Microsoft announced on Monday that company veteran Craig Mundie has stepped down from his post as chief of research and will retire in th...
  • Dr. Dre Top As The New Hip-Hop’s Top Earner
    Six years ago Dr. Dre was walking   for more click here
  • Microsoft new Windows, tablet
    US computing giant Microsoft on Tuesday gave an early peek to the key Chinese market of its new tablet computer and Windows 8 software, pr...
  • Thought words
    “ Greatness lies not in being strong, but in the right using of strength. ” — Henry Ward Beecher
  • How to Move Your Email to Another Mac
    If you use Apple's Mail application, there will probably come a time when you'll want to move your email messages and email account...
  • How To SSH Hop With Key Forwarding from Windows
    In this guide we’ll explain how to SSH to a Linux machine from Windows with your public key, using Putty & Winscp. In addition, we wil...
  • Japan's largest solar and wind power project breaks ground
    Seven Japanese companies have been celebrating the ground breaking of their solar and wind power project at a ceremony held today at the ...
  • How to Recover a Deleted File
    It’s happened to most of us. You delete a file and realize you need it back. This guide will explain when you can get that file back and how...

Categories

  • 3 D printers
  • 360s
  • amazon
  • android
  • animation
  • apple
  • bing
  • book
  • boxee
  • browser
  • china
  • chrome
  • console
  • dicaprio
  • domain
  • ecommerce
  • facebook
  • ferrari
  • finland
  • gadget
  • galaxy
  • games
  • gmail
  • google
  • hosting
  • HTC
  • internet
  • ipad
  • iphone
  • iphoto
  • iwatch
  • japan
  • keyborad
  • lenovo
  • linux
  • lunar
  • microsoft
  • mobile
  • moon
  • movil
  • ms
  • names
  • new tech
  • Nokia
  • online
  • password
  • pc
  • phone
  • retails
  • samsung
  • search
  • smartphone
  • software
  • space
  • tablet
  • tech
  • text messages
  • track
  • trip
  • usres
  • web
  • whatsapp
  • whois
  • window
  • words
  • xbox

Blog Archive

  • ▼  2013 (160)
    • ►  December (1)
    • ►  November (9)
    • ►  September (5)
    • ►  August (8)
    • ►  July (19)
    • ►  June (12)
    • ►  May (23)
    • ►  April (3)
    • ►  March (5)
    • ►  February (18)
    • ▼  January (57)
      • Google Street View now features Grand Canyon
      • How You can Create Free Ringtones for an iPhone
      • HP adopts Google's Chrome Operating System
      • New Blackberry 10 better and entertaining
      • New Apple iOS 6.1 has been Jailbroken
      • Java with Continuous Security Holes
      • Google Plus overtakes Twitter
      • What To Do If You Get a Virus on Your Computer
      • How to See if Your Hard Drive is Dying: tech repair
      • How to Use: A Windows Installer Disc to Back Up Yo...
      • Forbes 2013: African Richest Woman
      • About London’s Underground.
      • How to start a blog
      • The world View From International Space Station
      • Desire U. : New HTC Smartphone
      • Wii U through the eShop
      • Swipp : Facebook competitor
      • New Galaxy S IV to Charge itself Wirelessly
      • Xperia Tablet Z-The Most Thinest Tablet in the World
      • Google Image Search Gets New Look
      • Laptop without Mouse: controlling it with by movin...
      • Kim Dotcom starts new file-sharing site
      • Music sales in the Nordic country rose $145.4 million
      • The Secret of GOLD: Show Talk Money
      • History Of AirForce One Presidential Plane
      • US President plane Airforce One cost $180,000 an h...
      • Shakira : shower for underprivileged kids
      • motivational inspiration
      • China internet Users hits 564 million
      • "Zero Dark Thirty"
      • Claire Danes: Best actress
      • Samsung Galaxy S smartphone sales toppes 100millio...
      • Reddit co-founder Aaron Swartz is dead
      • Disable Java, says US Government
      • Microsoft cuts back in Germany: why?
      • Facebook tests steep fees of $100 to message stran...
      • Japanes tech company pays employee $11,200 to lear...
      • Sharing an iPhone Contact with a Friend
      • Microsoft to turn off Windows Messenger on 15 Marc...
      • How You can Schedule Your Mac to Automatically Sleep
      • China has built a Supersonic plane to fly between ...
      • HD" high definition of 4K TV with multiscreen
      • Free WiFi access by Google for entire NY City nei...
      • The World Most Advanced High Tech Yacht: The Eclipse
      • How to Recover that Photo, Picture or File You Del...
      • How to Service Your Own Computer: 7 Easy Things Co...
      • Hulu chief executive leaves
      • Digital music sales in the US topped 1.66 billion
      • Toyota new self-drive car: High tech
      • How To Creating and Deleting Files Through Code in...
      • Apple, Google gain in US smartphone market: survey
      • Google exec's Visit North Korea visit
      • India's Infosys is to cut 'up to 5,000 jobs'
      • WAS JUSTIN BIEBER PAPARAZZI KILLED?
      • Ubuntu operating system on smartphones and Tablets.
      • LG Has begins sales of next-generation TV
      • Sony has stop making PlayStation 2 in Japan
  • ►  2012 (340)
    • ►  December (25)
    • ►  November (34)
    • ►  October (24)
    • ►  September (27)
    • ►  August (26)
    • ►  July (46)
    • ►  June (83)
    • ►  May (42)
    • ►  April (33)
Powered by Blogger.

About Me

Unknown
View my complete profile