Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. File function with ftp

File function with ftp

Scheduled Pinned Locked Moved Web Development
question
6 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    hiral_shah
    wrote on last edited by
    #1

    Hi there, I am trying to check that if the file is already there in a folder of ftp or not with following: file_exists("ftp://ftpUserName:ftpPassword@ftpAddress/ftpUploadFolder/folderName/fileName.doc") but I can not get the result and the same for 'filesize()' function. If you know the way then please tell me. Thank you in Advance.:)

    -------------------------------------------------------------------------------------------------- Hiral Shah India If you think that my question is good enough and can be helpful for other then don't forget to vote. :)

    B 1 Reply Last reply
    0
    • H hiral_shah

      Hi there, I am trying to check that if the file is already there in a folder of ftp or not with following: file_exists("ftp://ftpUserName:ftpPassword@ftpAddress/ftpUploadFolder/folderName/fileName.doc") but I can not get the result and the same for 'filesize()' function. If you know the way then please tell me. Thank you in Advance.:)

      -------------------------------------------------------------------------------------------------- Hiral Shah India If you think that my question is good enough and can be helpful for other then don't forget to vote. :)

      B Offline
      B Offline
      Bradml
      wrote on last edited by
      #2

      Those functions mainly will only work on the local file system. You can use the:

      is_readable('LOCATION');

      function which should work for FTP but other than that you may need to use the PHP functions to determine the size.


      Brad Australian - Captain See Sharp on "Religion" any half intelligent person can come to the conclusion that pink unicorns do not exist.

      H 2 Replies Last reply
      0
      • B Bradml

        Those functions mainly will only work on the local file system. You can use the:

        is_readable('LOCATION');

        function which should work for FTP but other than that you may need to use the PHP functions to determine the size.


        Brad Australian - Captain See Sharp on "Religion" any half intelligent person can come to the conclusion that pink unicorns do not exist.

        H Offline
        H Offline
        hiral_shah
        wrote on last edited by
        #3

        I wrote following code in php : $uploadDir = "ftp://$ftpUserName:$ftpPassword@$ftpAddress/$ftpUploadFolder/$folderName/$fileName"; if(is_readable($uploadDir)) $msg = "$fileName is already exist. Your File is Not Uploaded"; else $msg = "File Uploaded"; I am uploading a file that is already exist yet it is showing me the secons message that is "File Uploaded"

        -------------------------------------------------------------------------------------------------- Hiral Shah India If you think that my question is good enough and can be helpful for other then don't forget to vote. :)

        B 1 Reply Last reply
        0
        • H hiral_shah

          I wrote following code in php : $uploadDir = "ftp://$ftpUserName:$ftpPassword@$ftpAddress/$ftpUploadFolder/$folderName/$fileName"; if(is_readable($uploadDir)) $msg = "$fileName is already exist. Your File is Not Uploaded"; else $msg = "File Uploaded"; I am uploading a file that is already exist yet it is showing me the secons message that is "File Uploaded"

          -------------------------------------------------------------------------------------------------- Hiral Shah India If you think that my question is good enough and can be helpful for other then don't forget to vote. :)

          B Offline
          B Offline
          Bradml
          wrote on last edited by
          #4

          Try using the built in FTP functionality then, this is what it is meant for.


          Brad Australian - Christian Graus on "Best books for VBscript" A big thick one, so you can whack yourself on the head with it.

          1 Reply Last reply
          0
          • B Bradml

            Those functions mainly will only work on the local file system. You can use the:

            is_readable('LOCATION');

            function which should work for FTP but other than that you may need to use the PHP functions to determine the size.


            Brad Australian - Captain See Sharp on "Religion" any half intelligent person can come to the conclusion that pink unicorns do not exist.

            H Offline
            H Offline
            hiral_shah
            wrote on last edited by
            #5

            Even I used is_file("fileName") function too but the result is not proper.

            -------------------------------------------------------------------------------------------------- Hiral Shah India If you think that my question is good enough and can be helpful for other then don't forget to vote. :)

            B 1 Reply Last reply
            0
            • H hiral_shah

              Even I used is_file("fileName") function too but the result is not proper.

              -------------------------------------------------------------------------------------------------- Hiral Shah India If you think that my question is good enough and can be helpful for other then don't forget to vote. :)

              B Offline
              B Offline
              Bradml
              wrote on last edited by
              #6

              Ok here is what a quick toss around of ideas in my head brought up:

              //Connect to the FTP server

              //$con = the FTP connection
              //$fileName = the requested file name

              $fileList = ftp_nlist($con, "/upload/Directory/etc");

              if(in_array($fileName, $fileList)){
                  echo 'File already exists!';
                  exit();
              }

              Last modified: after originally posted --


              Brad Australian - Bradml on "MVP Status" If this was posted in a programming board please rate my answer

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups