Results 1 to 8 of 8

Thread: [RESOLVED] get Filesize using a network path

  1. #1

    Thread Starter
    PowerPoster jcis's Avatar
    Join Date
    Jan 2003
    Location
    Argentina
    Posts
    4,430

    Resolved [RESOLVED] get Filesize using a network path

    I'm working under Windows XP (Apache + PHP), if I use FileSize() with a local path it works fine, but not when passing a path in a shared folder in my network like:
    PHP Code:
    Echo FileSize("\\Anothercomputer\Sharedfolder\Filename.txt"); 

  2. #2
    PowerPoster
    Join Date
    Sep 2003
    Location
    Edmonton, AB, Canada
    Posts
    2,629

    Re: get Filesize using a network path

    the backslash ("\") is an escape character in PHP. To PHP, you're trying to open:
    Code:
    \AnothercomputerSharedFolderFilename.txt
    try:
    PHP Code:
    echo filesize("\\\\Anothercomputer\\Sharedfolder\\Filename.txt"); 
    in each instance where you want a backslash, you must escape it using the backslash ("\\").
    Like Archer? Check out some Sterling Archer quotes.

  3. #3
    Frenzied Member
    Join Date
    Jan 2008
    Posts
    1,754

    Re: get Filesize using a network path

    You can find out more about Strings here: http://www.php.net/manual/en/language.types.string.php

  4. #4

    Thread Starter
    PowerPoster jcis's Avatar
    Join Date
    Jan 2003
    Location
    Argentina
    Posts
    4,430

    Re: get Filesize using a network path

    Quote Originally Posted by kows View Post
    the backslash ("\") is an escape character in PHP. To PHP, you're trying to open:
    Code:
    \AnothercomputerSharedFolderFilename.txt
    try:
    PHP Code:
    echo filesize("\\\\Anothercomputer\\Sharedfolder\\Filename.txt"); 
    in each instance where you want a backslash, you must escape it using the backslash ("\\").
    Thanks, i'll try this today at work.

  5. #5

    Thread Starter
    PowerPoster jcis's Avatar
    Join Date
    Jan 2003
    Location
    Argentina
    Posts
    4,430

    Re: get Filesize using a network path

    This doesn't work for shared folders on other computers, any known trick for this?

  6. #6
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: get Filesize using a network path

    You can use single quoted strings as well.
    PHP Code:
    filesize('\\who\where'
    I don't know of any reason why you wouldn't be able to call filesize for a file over SMB.

  7. #7
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: get Filesize using a network path

    I don't know why you would want to give your web server access to resources via SMB. I would much prefer to lock it away in the furthest corner of the network possible.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  8. #8

    Thread Starter
    PowerPoster jcis's Avatar
    Join Date
    Jan 2003
    Location
    Argentina
    Posts
    4,430

    Re: get Filesize using a network path

    I'm developing an interface that takes data from a MySql database in a given server and it creates an output file also in that server all this is done using MySql, now the part i need to do using PHP is opening this file, see how many bytes it is, writing that number to other file (a control file) and finally zipping it to gz. All this is already done and working but to make it work i had to copy that output file generated by MySql to my computer and then running my php file. I wanted to simplify my developing a bit by making my php file work directly with the file in the server, and this file was in a shared folder in the server.

    But: I'm thinking that this PHP file i'm working with locally, will be in that server when all this becomes productive, since this interface will run scheduled most of the times with a CRON task.

    Why do they use PHP? maybe they want to call this via web? i don't know. I just know this is how they want these interfaces and i'm now just learning about all this web stuff since most of my experience has been desktop applications till now.

    Marking thread resolved, Thank you all.
    Last edited by jcis; Mar 17th, 2011 at 11:10 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width