Check If A File Is Local
Is There A Function Or Method Which Can Check Wether A File Is Local.
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Check Local Computer Script
I am trying to do is create a script that searches the local computer of the user and if a filename is there, it will upload it to the mysql database. Then, another script that searches for a filename on the database and if it's there, to ask the user if they would like to send it to their local computer. Any suggestions?
Posting Local File Info To A Php File!
I have a script that I run locally and im trying to get the info to post to a php file so that I can view it in a browser. What I need to know is how to set up the receiving php to post it to the .html . Now I thought it went along the line of creating the php file and putting it on the root of the server then running the local script against a that php info file and it would dump the info to a browser but it wont work like that (I'm guessing cause it's a local script and not on the web) I know this line is sending it to the .php in that directory but I don't know how to set up the receiving php I guess is my problem. gosub phpsend www.xxxxxxxxxxxxx.com /xxxxx/xxxxxxxxx.php %sendstring I guess what I need to know is whats the best way to post the received data to a browser after the script runs. Or to set up the receiving php file as for outputting it I can create the page I just need to know how to receive it .
Writing To A Local File
We have a PHP/MySQL database application. A user would like to be able to run a routine to read selected data from the database and export a flat file to their local C: drive. After reviewing the documentation and posts, it is not clear how to do this, or even if it is allowed by the browser. If someone could point us in the right direction, we would greatly appreciate it. The application is hosted on a Linux server. The users are required to use Internet Explorer running on Windows 2000 or XP (we also use VBScript).
Can I Launch A Local .bat File With PHP?
I need to write small web app that can launch a few .bat files from a local machine. Is this possible with PHP, or would javascript be a better option? All i need to do is select the file (some HTML) then have a button to execute.
Reading Local File Not On Server
I am trying to parse a file which is located on the users local drive and then take this data and put it into the mySQL DB. However, I get errors when I pass in a file path such as C:Documents and SettingsAdministratorDesktopfooSLInfo.txt.
Read File On Local Drive
lets assume that the sysadmin granted to read those files, what php functions needed? can u give me ur ideas how to do it?
How To Process A Local File Rather Than Just Read It
I can read a local file with fopen("myFile.php"); However this gives me the source of the file (i.e. php code). I want to get the results of the file after it has been evaluated (i.e. HTML). The obvious way of doing this is include 'myfile.php' However, I want to process the evaluated result. For example: echo htmlentities( include 'myfile.php' ); This doesn't work because the result of the include statement is true or false rather than a string. I'm sure this is very simple, but I'm just learning.
Writing A Local XML File From A Parsed URL? Similar To RSS
I am trying to pull the XML data from the following stream: http://......and write it to a local file. Actually, what I would like to do is take the above stream and display it into a website... much like displaying RSS feeds on a webpage. I looked at javascript, but someone there pointed me to the PHP group. I may not have worded the subject correctly.
Copy Large XML Output To A Local File
I have a URL that when called generate a very heavy XML Feed like: www.domain.com/generateXML.php?id=products when i call this URL in the browser i can see a very long XML file generated containing different information..i want to copy this all output to a local file on my server so that i can use that file's info for different tasks on my site...PHP Code:
PHP-generated Link To Local File Doesn't Work When Clicked On. Why?
I'm running an Apache server on my own computer (Windows XP Pro). I wrote a simple PHP script (called test3.php) that I'm running by putting the following URL in the address bar of the browser (Firefox) .... http://localhost/test3.php The script generates the following link using the echo statement ... <a href="file:///C:/pictures/xyz.jpg"> Picture </a> ("C:/pictures/xyz.jpg", as you can guess by now, is an image file on my harddrive, but it's not in the document root). When I clicked on the link, nothing happened. However, if I RIGHT-click on it and select "Copy link location" (which copies the URL to the clipboard) and then paste the URL into the address bar of the browser, the picture then displays correctly. Why did it not work when I clicked on the link the first time, but it only worked when I pasted the link to the address bar? Is there some special notation/syntax that I need to use to get this to work properly?
How To Populate HTML Table From Local Text File.
I am looking for a way to populate an HTML table from an external local text file which looks like this: DATE/TIME LAT. LON. DEPTH. ML. -------------------- ---------- ---------- ------- ------- 21/03/2005-04:06:03 XX,XX XX,XX 171 3,42 21/03/2005-12:23:53 XX,XX XX,XX 500 5,4 21/03/2005-12:43:10 XX,XX XX,XX 553 5,38 21/03/2005-18:47:51 XX,XX XX,XX 162 3,91 21/03/2005-19:29:49 XX,XX XX,XX 500 3,51 21/03/2005-20:04:51 XX,XX X,X 75 3,72 The file could have more rows (DATA) that I show here. The file is provided to me on a daily basis and I have to update a web page daily with the contents of the file. I considered using JavaScript embedded in the HTML page but I am a newbie on what scripting for the web it refers. How can I populate the HTML table with this text file which changes everyday. Also, is it possible to use php client-side only, without a server?
Copying File From Hosted Remote Sever To Local Machine
I am trying to use php to automate the copying of a file from my remotely hosted directory to my computer. I have put together the following but it will only do the copying from one directory to another on the remote server. Reading the postings on these functions they suggest that it can be done but it appears to be the case if your are hosting your site on the same machine you want to copy the files to. Does anyone know if there are functions in php to do the transfer from remote server to my machine or if the code below will acheive this with modification? <?php $ftp_server = "xxxxxxxx"; $ftp_user = "xxxxxxx"; $ftp_pass = "xxxxxx"; $local_file = 'myfile.txt' $server_file = 'myfile.txt' // set up a connection or die $conn_id = ftp_connect($ftp_server) or die("Couldn't connect to $ftp_server"); $login_result = ftp_login($conn_id, $ftp_user, $ftp_pass); // check connection if ((!$conn_id) || (!$login_result)) { die("FTP connection has failed !"); } // try to change the directory to myfilesdirectory if (ftp_chdir($conn_id, "myfilesdirectory")) { echo "Current directory is now: " . ftp_pwd($conn_id) . ""; } else { echo "Couldn't change directory"; } if (ftp_get($conn_id, $local_file, $server_file, FTP_BINARY)) { echo "Successfully written to $local_file"; } else { echo "There was a problem"; } // close the connection ftp_close($conn_id);
Check File
I'm trying to find a way to search a text file for a certain key, and there will be one key on each line. I'm hoping it could return 0 if there's no match, and 1 if there is. I'm familiar with this in other languages, but I can't find how in PHP you can read a certain line of a file. I can get most of the code already: $var=0; for($i=1;$i<=file_lines();$i+=1) { if (file_read_line()=="key") { $var=1;}} But I'm sure you spot two probmlems, they are file_lines() and file_read_line(). Does anybody know the proper replacements, or a simpler way?
Check File Age.
I am tring to make a script that i will turn into a cron job. Idealily it would check the age of the file and then figure out if it is more then 48 hours old and if it is it will delete it. i have figured out how to check the age and how to delete the files, but how would i find out if they are 48 hours old?
How To Check If File Exists
Have a look in a folder, check if there is a file and if there is display one thing, if not display something else. example: $result=mysql_query("select * from my_table"); while($row=mysql_fetch_object($result)) { if(fodler/$row->name.txt exists) { display this} else { display thus } }
Check If A File Has Been Included Before?
I want my scripts to be warning and error free. Is it possible to check is a file has already been included as part of a "require", "require_once" or "include" call in the script? I guess I could just include everything and turn warnings/errors off, but I'd prefer not to do that.
How To Check For Existence Of A File?
Im programming a shopping cart in php with an administrative back end. My question is this: whenever someone uploads an image for a product, I have to check if an image by the same name exists already. I've done this in perl before with a simple while while(-e "/path/to/$image"){ //do my image renaming here} The -e means while exists this file, keep renaming the current file until it has a unique name. So in php I've never done this before and Im trying to find out a good way to go about doing it. I've looked through the manual and cant really find anything.
File Name Case Check
Has anyone come across a utility to check the case of a filename versus a php page? I develop locally on a windows machine (Know Know) then upload to a Linux and everything works usually works fine.
Check File Type
I use this to check my files type: $fileextension = $_FILES['file']['type']; But it returns the files MIME type, such as image/x-png. How can I get it to check the files actual extension? Such as .mp3 and .zip etc.
LOAD DATA LOCAL INFILE - Workaround For Local-infile=0
I'm using a PHP script for updating my database which relies on the "LOAD DATA LOCAL INFILE" command. As my provider recently updated the MySQL-database, he changed the "local-infile" setting to zero, i.e. my update-script doesn't work anymore (=> "The used command is not allowed with this MySQL version"). Is there a work-around to fix this problem? I though about the mysql_options command, but to frankly speaking, I have no clue how to use it and couldn't figure out how to properly use it even after reading the manual ... anyone who could help?
Check A File Exists In Another Directory
I am writing a script that will insert a link to the page, but before it does that, it must check to see if the page exists. I can use the file_exists($page_file) function, but it seems to only work if the file is in the same directory where the script executes. My script is supposed to find the script in another directory, but it does not find them and returns false. Does anyone know how to solve this problem?
Check File Size Before Upload?
Is there any way to check file size before upload? The reason for asking is that if a user wanted to upload a large file .. say 10 mb or so .. the script suggested by php manual would require the user to wait until at least the file is uploaded to the tmp directory on the server before checking the size. That is obviously an inconvenience. I have tried google and all sorts of searches but to no avail. Have also tried a little javascript function that copies the file's name (and full path) to a hidden field in the hope that I could use filesize ($fileName) to get the size on the client's computer before it starts uploading. That didn't work either (with error : there is no such file or directory etc.. I assum it is because php is a server-side script and it doesnt or cannot read the clients directory system.
Check File Extension Properly
here's my code. Can't get it to check file extension properly or file size...had it working before but not sure why it's buggy now. } elseif ($photo) { $ext = strtolower(substr($photo, -3)); if ($ext == "peg") { $ext = "jpg"; } if ($ext != "gif" || $ext != "jpg" || $ext != "jpeg" || $ext !="bmp" ) { $focus = "photo"; $msg = "Please provide a valid gif, jpeg, or bmp photo"; } else { $photo_size = getimagesize($photo); if ($photo_size > 25000) { $msg = "Photo must be smaller than 25k."; }}} elseif { etc, etc. } else { dbqueries...
Error Check Before Append To File.
I want to be able to append my httpd.conf file from a web browser to make adding virtual hosts a little easier. I've got a simple form that passes two variables. $virtualhost and $subdirectory. what I want to be able to do is read the file and make sure that there is not already a domain name and subdirectory in the file. Code:
How Can I Check If A File Is Completely Uploaded...???
i've created an application for a customer where the customer can upload ..csv-files into a specified ftp-directory. on the server, a php-script, triggered by a cronjob, reads all the data, imports it into a mySQL database and deletes the .csv-file after the import. so far, so good. but in some cases the cronjobs starts running when the file is not completely uploaded. so a part of the data is truncated. :-( is there any method in php to check if a file is completely uploaded via ftp or not? i didn't find anything about this on php.net and it would be great if someone could help me with this problem.
Check Clientside File Size
i have an upload mechanism on my website and want to check the filesize on the client size. is this possible?
Function To Check If A File Exists Or Not?
Does anyone know if there is a function to check whether a file exists or not? Something like readfile(), but which DOESNT actually output the file. I'm trying to write an upload script, so something like this: if (@readfile("$filename")) { echo "This file exists already"; } else { echo "This file does not exist"; } Anyone know?
Check The File Size Before Upload
I am creating a PHP site where end users are required to upload images. I need to ensure that the end user doesn't upload a file that too big. I can't find a way to set this limitation in the HTML, and checking it using PHP is too late as the file is already uploaded. Is there some JS that I can use to check the file size client-side? (It's also important that whatever JS I use, if any, doesn't contain Js scripts that will be a lot of dectors be considered spyware...I do realise that the end user can disable JS and also that they can alter settings of thier spyware software but if I can't cater for everyone I can at least cater for normal end users). Background: This is for uploading images of houses to a realestate site, a lot of people that use this (including realestate staff members wouldn't or don't resize images prior to uploading.
How To Check/verify File Types?
I'm working on some file uploading code, and need to check the file type and then verify that it's either ".doc, .txt, .pdf, or .xls" -- if it's not one of those, display an error and not upload it. But, I'm not sure how to do this; I think I want to implement $_FILES[my_file_name]["type"] somehow, but I just don't know where to begin or how to implement it??? Code:
Check If A File Is In Windows-1250
i need to check a file to see if its encoded in windows-1250 so ican convert if it is... i cant just convert the files that are in the correct encoding because this adds some strange characters where there shouldnt be does anyone know how i can check? ie if (windows1250($doc)) { iconv(...); } how do i do that check?
How To Check Size Of File Before Upload To Serevr
is there anyway that i can check the size of file on client side before uploading file to server? suppose the user uploads file of 10 mb then the server will know the size is 10 mb after the file is uploaded to server which wastes the bandwidth so what i want to check is that the server first checks the size of file to upload and if it is o.k. then and then only the file will be uploaded..
Problems With Check File Upload Is Jpeg
It seems that the following code works for the majority of my visitors, however for very few, it throws back that the image they upload is not a jpeg, even though it is and we have tested the image it as well with no problem. So its on some computers. Im thinking that there must be a mime type missing, but we can't seem to get it. It varies from Firefox and IE. code:
PHP4 -> PHP5: Require Does Not Check File Directory Anymore?
In my application I have lots of require statements that include files residing in the same directory: index.php requires: require_once($_SERVER['DOCUMENT_ROOT']."/modules/cms/classes/page.php"); page.php requires: require_once("common_functions.php"); Now I try to install the application on a PHP5 server (Apache), and this does not work anymore. In the PHP4 -> PHP5 migration chapter of the manual I did not find any notes on a change of the require/include behaviour, not checking the directory of the calling file anymore; nor did I find it googling. So I am not sure if it is an undocumented migration issue or just a setting. I understand that I can use: require_once(dirname(__FILE__)."/common_functions.php"); But this means rewriting the whole application. Is there a way to change this behaviour via ini_set()? (As I am in a shared hosting environment I have no direct access to the php.ini.)
Local Value Safe_mode
In my phpinfo, in PHP core i see "Local Value" and "Master Value" if i change my php.ini file than only master value changes, where do i change the "Loval Value" . I run Apache/2.0.48 on Linux/SuSE
Add Handler ? #!/usr/local/bin/php
I have a web page like this #!/usr/local/bin/php <? echo "hello"; ?> It always shows the first line as text output. Does anyone know how to let web server or intepreter ignor this line. I try to add the following line in the httpd.conf AddHandler cgi-script .php And make the file executable. It shows " internal server error". Since this package has around 40 or 50 pages. I do not want to get into each file and comment it out. Any idea about this?
Local Host
when i am trying to connect a database with this: mysql_connect (localhost, username, password); how do i find my local host?
Local Mail
i am running a home server but i can't get mail() to work. what will i do if i have no mail server? im using apache/linux/sendmail.
Local Fsockopen()
I am tring to develop a site that conects via sockets. I am doing the development on a localhost Apache server here's a small code example:- <?php $host="127.0.0.1"; $socket=fsockopen($host,80,$errno,$errstr,50); if(!$socket){echo "NO CONNECTION".$errno.$strerror;} else { fputs ($socket, "GET/apache/htdocs/phpinfo.php HTTP/1.1"); $info='' while (!feof($socket)) { $info.=fgets($socket,1024);} fclose ($socket); echo $info; I'm having a problem with the fputs() line. After the GET/ sataement I am trying to direct he socket to a file, so I will be able to read/write but the fputs() doesn't seem to accept any path I put into it. The socket works ok because If I leave out the path I am sent o the apache intro page on my localhost.
Local Variables
I am running a virtually hosted domain on a server that I have root access on also. I rented the server, but the hosting company supply no information on the setup. I'm forced into using their control panel to add domains. Running a phpinfo() on a virtual domain I have found that although I have set safe_mode to off in the php.ini file something is setting the local value for safe_mode to On. There are no .htaccess files in the heirachy of folders to the virtual domain. I've checked the <virtual hosting> directives in the httpd.conf and I cant see anything there that might be doinng this.
PHP On Local Machine
Back in 2004 I installed PHP, Apache and MySQL on my local machine to do some testing. I have not used it since. I just tried to browse one of my .php test files in IE and it opened up in Dreamweaver! Everything seems to be in place where I left it, I restarted Apache just in case - but no joy. Is there something simple that I have forgotten to do? - something I should have started up? - or something I can check? I would like to avoid reinstalling the software if possible as I recall having a few "teething problems."
PHP In Local Development
i got this error: Fatal error: Failed opening required 'mainfile.php' (include_path='c:php4pear') in d:PHPWEBmyPortalmodulesSearchindex.php on line 19 im doing a local development for testing my php mysql codes. in my little knowledge, i think the error is in the configuration of the php but i don't know exactly how to fix this.
Regex - Matching Local IPs
I'm just trying to get PHP to sniff out local users using preg_match; can anyone spot my error? preg_match("/(192.168.(0-9){1,3}.(0-9){1,3})¦(10.(0-9){1,3}.(0-9){1,3}. (0-9){1,3})¦(172.(16-31).(0-9){1,3}.(0-9){1,3})/",$_SERVER['REMOTE_ADDR'])
|