PHP Front To Back [Part 19] - File System Functions

แชร์
ฝัง
  • เผยแพร่เมื่อ 14 ต.ค. 2024
  • In this video we will look at some functions to work with files, folders and paths such as basename(), dirname(), file_get_contents(), fopen(), fread() and much more
    CODE: Code for this video
    www.traversymed...
    BROWSER EXTENSION: Momentum
    chrome.google....
    EDUONIX COURSES: Please use affiliate links from website below
    www.traversymed....
    SUPPORT: We spend massive amounts of time creating these free videos, please donate to show your support:
    www.paypal.me/t...
    / traversymedia
    FOLLOW TRAVERSY MEDIA:
    / traversymedia
    / traversymedia
    / bradtraversy

ความคิดเห็น • 52

  • @teraspa1332
    @teraspa1332 6 ปีที่แล้ว +6

    I am a college student and i am doing my last semester project, i am glad i saw your videos about php you helped me a lot with these videos . You are a better teacher from any other teacher at my college!!

  • @pepeback
    @pepeback 7 ปีที่แล้ว +40

    you are like family ;) after so many good videos and the honest way you sound

    • @TraversyMedia
      @TraversyMedia  7 ปีที่แล้ว +8

      Thank you buddy. I appreciate that

  • @bobscherr1
    @bobscherr1 5 ปีที่แล้ว

    Nice series broken down to small pieces so that it is easy to follow and easy to go back to topics that need to be refreshed. Also Brad takes the time to show the alternative scenarios when entering lines of data.

  • @DrazV2
    @DrazV2 5 ปีที่แล้ว +6

    If anyone else was confused like I was, "fread" on line 62 takes two parameters, the $handle we defined and a file size it reads up to. To read the whole file we used the filesize function to read every byte of the file.

  • @aymanmakhoukhi3591
    @aymanmakhoukhi3591 5 ปีที่แล้ว +6

    I used to hate php but i am loving it now, thanks man keep it up, we really appreciate your efforts, so useful

  • @bugraates478
    @bugraates478 3 ปีที่แล้ว

    Some of instructor's courses are very long but we can not feel we learned comperhensive information. But after watching your videos, I am feeling very good and completed about course content. Thank you so much for that I am feeling confident about subjects that you taught

  • @realwizardry834
    @realwizardry834 7 ปีที่แล้ว

    Fantastic videos Brad. I've been working through your PHP playlist for the past couple of days and you are a fantastic teacher.

  • @cagrioz9798
    @cagrioz9798 7 ปีที่แล้ว +1

    I really liked this series please keep sharing video Brad. Your all videos awesome you are really good teacher..

  • @ahmadhabibi9582
    @ahmadhabibi9582 3 ปีที่แล้ว

    Thank you sir i learn a home of knowledge from your channel i once again appreciated

  • @enrico8730
    @enrico8730 7 ปีที่แล้ว +2

    Yes! Been looking for this type of file implementation with php. Thanks!
    Will you do any tutorials on chatbots? Thinking it'll be a good add ons to ur php MySQL ecommerce tutorials

  • @Ali-aljabri
    @Ali-aljabri 4 ปีที่แล้ว +1

    If you type mkdir() then get a "permission denied" error just go to file folder then right click and click "Get Info" in "Sharing & Permissions" change all from "Read only" to "Read & Write" . And for windows users just right click on the folder => properties then remove checkbox form "Read Only"

  • @LatinoWebStudio
    @LatinoWebStudio 3 ปีที่แล้ว

    Thanks for so much for the video series! I've learned so much and will take your Udemy course right after.

  • @racingrival4701
    @racingrival4701 6 ปีที่แล้ว

    thanks for the php tutorials...it has been a blast so far. keep do it...your are great teacher.

  • @gracialonignasiver6302
    @gracialonignasiver6302 3 ปีที่แล้ว

    Notes:
    1:27 - basename() function returns the filename from a path.
    2:00 - basename(path, '.php'); returns the filename without the extension.
    2:40 - dirname() function returns the directory name from the path.
    4:03 - file_exists() function returns a 1 if the file exists. (files and folders)
    4:57 - realpath() function returns the entire path of a file.
    6:00 - is_file() function returns a 1 if the file exists. (only files)
    6:38 - is_writable() function returns a 1 if the file is writable.
    7:14 - is_readable() function returns a 1 if the file is readable.
    7:40 - filesize() function returns the size of the file. (in bytes?)
    8:14 - mkdir() function creates a directory. (creates folder)
    8:46 - rmdir() function deletes a directory as long as there are no files inside.
    9:53 - copy(param1, param2) function copies a file into a new file. (param1 - old copy, param2 - new copy)
    10:25 - rename(param1, param2) function renames a file. (param1 - old name, param2 - new name)
    11:00 - unlink() function deletes a file.
    11:43 - file_get_contents() function writes from file to string.
    12:18 - file_put_contents(filename, data) function that writes to file

  • @joe-powell
    @joe-powell 4 ปีที่แล้ว

    Awesome series

  • @cagrioz9798
    @cagrioz9798 7 ปีที่แล้ว +1

    Brad your courses high quality thanks for that and please upload new videos :)

  • @michaelgtz4873
    @michaelgtz4873 4 ปีที่แล้ว

    Thanks a million for the great course, Brad. At 14:00 appending to a file seemed a bit too complicated to me and i was wandering if there is a way to do it in less code and res usage. I've found that file_put_contents() takes its mode as a parameter, so " file_put_contents($file, 'goodbye world', FILE_APPEND); " would work as well.

  • @TheFippe
    @TheFippe 7 ปีที่แล้ว +4

    "Lets pass in $file ........ and we get nothing ........ thats because there is no $file2 .... " lmao so calm and steady was funny.

  • @Knards
    @Knards 7 ปีที่แล้ว +1

    Good reminder to php I seldom use

  • @cagansit7268
    @cagansit7268 7 ปีที่แล้ว

    Thank you Brad, you are the best!

  • @michaeldalby1971
    @michaeldalby1971 7 ปีที่แล้ว

    Hi Brad, as always great content (audio and visuals) with superb pacing. Can't wait to you do the follow-up video on PHP with a database.
    just out of interest all of your files reference were to 'xxx.php' how can I use PHP but still have a .html type file (sorry if this is a dumb question but I'm a total newbie on Web software)
    cheers
    Michael

  • @robelseyoum1583
    @robelseyoum1583 5 ปีที่แล้ว

    I take my hat off to you Brad!

  • @rohinikumari4
    @rohinikumari4 3 ปีที่แล้ว

    you're a lifesaver for sure

  • @shozdott
    @shozdott 7 ปีที่แล้ว +7

    You have to be pissing alot of bootcamp peeps off ... I love It !!! hehe

  • @batyr71
    @batyr71 7 ปีที่แล้ว

    Great for beginners like me!

  • @adilmughal2251
    @adilmughal2251 3 ปีที่แล้ว

    Please Brad add more videos in this playlist

  • @limitless1692
    @limitless1692 5 ปีที่แล้ว

    Thank You for the course
    :)

  • @44_kamble_aditya_laxman12
    @44_kamble_aditya_laxman12 3 ปีที่แล้ว

    is it possible to create a .js file and edit/read/write it using these methods? And maybe use that .js file as a psuedo database ? maybe by inserting 'arreys in form of text'? ( just an experiment )

  • @aspsa6246
    @aspsa6246 3 ปีที่แล้ว

    Thank you for the video. I would like to use either 'dirname()' or 'opendir()' in PHP within the context of a WordPress site to access a directory that exists outside the context of a WordPress site's directory structure. For example, I have a collection of media files that are stored on a network attached storage (NAS) device and want to build a WordPress site that can access these files, as well as files that exist in other locally attached physical media (local hard drive, thumb drive, DVD drive, etc.) The rationale for this approach is to avoid duplicating these media assets by pulling them into my WordPress site's Media Library. Unfortunately, when I try to access these files with 'dirname()' or 'opendir()', WordPress returns a 'no such directory' found error message. I've tried to tracing the genesis of this error, and I do not think it necessarily relates to PHP. Instead, I suspect WordPress uses a security model out of the box that prevents one from accessing files that are not contained within a WordPress web site's directory strucuture. Your feedback is appreciated.

  • @omonkalite
    @omonkalite 5 ปีที่แล้ว

    Hello Traversy, please can you show me how to use the PHP id3_tags
    id3_​get_​frame_​long_​name
    id3_​get_​frame_​short_​name
    id3_​get_​genre_​id
    id3_​get_​genre_​list
    id3_​get_​genre_​name
    id3_​get_​tag
    id3_​get_​version
    id3_​remove_​tag
    id3_​set_​tag
    any help from you will be useful

  • @mohamedabutalola1407
    @mohamedabutalola1407 7 ปีที่แล้ว +1

    Great!

  • @NathanBudd
    @NathanBudd 6 ปีที่แล้ว

    Does the file extension trick for basename only work if you know the extension?

  • @robertcoffie8789
    @robertcoffie8789 7 ปีที่แล้ว

    Please waiting for the next video
    and kindly please make a tutorial on login system

  • @e8mile
    @e8mile 6 ปีที่แล้ว

    thanks

  • @hermanomark
    @hermanomark 6 ปีที่แล้ว

    damn very nice tutorial

  • @marvinmachitar7229
    @marvinmachitar7229 4 ปีที่แล้ว

    17:58 it should be r
    \ to move to next line... still, a good tutorial

  • @mohammedkamel9348
    @mohammedkamel9348 7 ปีที่แล้ว +1

    waiting for next video

  • @stuknowlton477
    @stuknowlton477 4 ปีที่แล้ว

    Freaking awesome

  • @troyf8488
    @troyf8488 3 ปีที่แล้ว

    Hello everyone. When practicing with the code. I noticed that ally my code is marked incorrectly right around the mkdir . Could this be caused by me running a different version of php ? I am using a wampstack with the most current php version.

  • @castmixer12
    @castmixer12 7 ปีที่แล้ว +1

    waiting for next video. (Y)

  • @daniellajohansson
    @daniellajohansson 7 ปีที่แล้ว

    I use Ubuntu and when I use the last thing we did (create *file2.txt* and write to it). It creates the file and write to it but I cant save the file. So I figured I have to go into file system and change privileges manually. and for some reason I cant even do that since I don't own the file. some "deamon"-thing owns it.
    It made me think about if you develop a website in Windows and deploy it on an Ubuntu system, can that give you problems you don't know before you test it (after you deployed it)?
    I'm not so used to Ubuntu and learn it because so many website companies use it. I must say I miss Windows where everything works out of the box (more or less). But I'm not giving up yet on Ubuntu.

    • @raphaelandrade555
      @raphaelandrade555 7 ปีที่แล้ว

      The folder you are is the /etc/var/www/html? if is, i recommend you check some tutorial about creating a virtual host, it make you able to work in another folder, then you'll have all the privileges

  • @ahmadabdulaziz9696
    @ahmadabdulaziz9696 7 ปีที่แล้ว +1

    When are we expecting the next video on PHP front to Back

    • @TraversyMedia
      @TraversyMedia  7 ปีที่แล้ว +3

      Should be this coming week

  • @successfulpeople
    @successfulpeople 6 ปีที่แล้ว +1

    In this video, I saw a lot of similarity with Python

  • @AbdullahAbbasAwan
    @AbdullahAbbasAwan 6 ปีที่แล้ว

    File Uploading is missing in this series

  • @christianpaul5224
    @christianpaul5224 2 ปีที่แล้ว

    Why is that filesystem functions do not work, I am using ubuntu.

  • @mohammedasif4086
    @mohammedasif4086 5 ปีที่แล้ว

    Hey how to work with CSV files?

  • @patrasculucian2403
    @patrasculucian2403 6 ปีที่แล้ว

    11:55 Hello World hh

  • @mohammedkamel9348
    @mohammedkamel9348 7 ปีที่แล้ว

    waiting for next video