|
-
Mar 9th, 2011, 02:31 PM
#1
[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");
-
Mar 9th, 2011, 04:32 PM
#2
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 ("\\").
-
Mar 9th, 2011, 10:20 PM
#3
Frenzied Member
Re: get Filesize using a network path
-
Mar 9th, 2011, 11:30 PM
#4
Re: get Filesize using a network path
 Originally Posted by kows
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.
-
Mar 10th, 2011, 01:25 PM
#5
Re: get Filesize using a network path
This doesn't work for shared folders on other computers, any known trick for this?
-
Mar 15th, 2011, 12:10 AM
#6
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.
-
Mar 16th, 2011, 06:36 PM
#7
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.
-
Mar 17th, 2011, 11:02 PM
#8
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|