Displaying A File Path
Does anyone know how (in PHP) you can display the path of the current file? ex. (Home > PHP > Templates).I know you can do it in JavaScript, but I'd prefer to use PHP.
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Displaying File Path In File Input Field
i have file input field in a form like this: <input name="isbn" type="text" size="25" value="<?php echo $_POST['isbn'] ?>" /> <input name="image" type="file" size="25" value="<?php echo $_FILES['image']['name'] ?>" /> when i press "submit" button, the same page gets loaded... if my $_POST['isbn'] is empty, i want to have the file path on "file input field" to redisplay on that same field... it's possible in text input field but i don't know of a way to do it in file input fields...
Get Php File Name WITHOUT Path
I have a page in Apache with a path like "localhost/projects/main.php" and I need to retrieve only "main.php", or whatever the current PHP page name is. Anyone would think that some of these methods should return the file name: $_SERVER['SCRIPT_FILENAME'] $_SERVER['SCRIPT_NAME'] $_SERVER['REQUEST_URI'] But *ALL* of those methods return "projects/main.php"... d'oh! How can I retrieve the file name ONLY, without path?
URL From File Path Name
I know there must be a function somewhere for converting a local file path name to the url path (i.e. /user/apache/htdocs/myDir/myFile.jpg to /myDir/myFile.jpg) but I can't find it! Can someone tell me what it is?
File Path
I was trying to use the ftp_put command. It worked for the files in the same directory as my php file, but if I try to fetch a file somewhere else on the server with the following syntax for the source file it doesn't work. "serverdirectory_pathfilename" also it didn't work with "//server/directory_path/filename" What is the correct way to access the file?
Get A File Name From A Path
Yes, this is almost like PARSE_URL, but no this is not what I want to do. Simplest way to explain it is by example. I want to turn this: ./`admin/plugins/top/*.php Into this: * I want to get the name of the script IN the file. The files PATH, is not going to be /`admin/plugins/top/. The paths will be ./`admin/plugins/* (top | middle | bottom). How would I convert these names?
Extracting The File Name From A Path?
I want to remove all from before the file name including the slash. $filename = "some/path/to/filename.txt"; or $filename = "some/other/path/to/filename.txt"; Is there a way to remove words that end with a slash? $filename[0] = preg_replace('/.*/','',"$filename[0]");
--with-config-file-path
I want php.ini in my own place, say /etc not default /usr/local/bin. So when I configure I use --with-config-file-path=/etc .... Easy !? It dose not work, well it configure, make and make install ok but still looking for php.ini in /usr/local/bin. A script with phpinfo() tells me it looks in /etc but it still php.ini from /usr/local/bin. Using: Slackware 10.1, Apache 2.0.54, PHP 5.0.4
Move File Path?
I'm trying to move some files on my server but I cannot get the path right. I've messed with this and can't get it right. Is there a way to debug the path of a file on the server? Here is what I'm trying to do. I have a upload.php file in root/beta/upload/upload.php and want to move a file in the root to root/beta/files but I get error below. What am I missing? $file = 'After.jpg' $newfile = '/beta/files/TestMe.jpg' if (!copy($file, $newfile)) { print "failed to copy $file... "; } Warning: copy(After.jpg): failed to open stream: No such file or directory in /hsphere/local/home/barkster/zipyard.com/beta/ThinUpload/TestUpload.php on line 5
Strings In File Path
How would I use a string in a file path? I want to use a string in an include but it doesn't work when I do this: $usertemplate = "default"; include('templates/$usertemplate/index_body.tpl');
Browse For File Path?
Is it possible for a user to click a button (i.e. Browse), point to a local document, or a document on a networked fileshare, and then the application would save the path to that document, but not actually upload the file? I.E.: 1. User clicks "Browse". (i.e. browses the filesystem just as he/she would if say opening a document from Word) 2. User selects the //fileserver/docs/document1.doc 3. When the user clicks ok, the application saves the path to the document. 4. The path is saved to a database with records and subsequent users can view that record and click the link to open the document from the fileserver.
Phpinfo() - Configuration File (php.ini) Path
Not really an important question, but does anyone happen to know how to modify the path displayed in the [Configuration File (php.ini) Path] section from phpinfo()? I was referred to the following URL, but that doesn't seem to do it: http://us3.php.net/manual/en/configuration.php
File Path Script Problem
I have a script that shows the path of the current file like so... Home > Directory > File.php The problem is that I don't want the current file name and link to be displayed.... Home > Directory How can I suppress the current file name/link from being displayed?
Validating Directory And File Path
I'm new wiyh PHP and would like to ask, what is the common way to check if directory path e.g. in url and file requested are in proper format? E.g. if I would give my homepage URL in format /usr/software/index.php it would be ok in my case but e.g. /usr//software/index.php would of course be wrong. I tried those parse_url() etc methods but they eat at least everything (or my php-version) and does not understand any errors. Could regular expression resolve this? I haven't use it much so, can anyone say how to test and notice that /usr//software/index.php is not in proper format?
Getting Absolute Path Name Of Resource File
How can I get the absolute path name of a file that I refer to within a script? I have a text file stored above the document root. The script defines a variable like this: $data_file = '../../data.txt' When I call the script from another page somewhere else from within the website structure of course the relative filename for the data file is wrong. All I can think of is to get the directory I'm currently in using dirname($_SERVER['PHP_SELF']) and strip off two layers using regular expressions. But isn't there a simpler way?
Path Getting Messed Up - Cannot Find A File
If I run the following code: exec ("swetest -edir$sweph -b$utdatenow -ut$utnow -p012 -eswe -flsj -g, -head", $out); all is well - PHP finds the program swetest and makes the calculations. But if I then insert this beforehand: $NetGeoHTML = file_get_contents($NetGeoURL, 99000); exec ("swetest -edir$sweph -b$utdatenow -ut$utnow -p012 -eswe -flsj -g,...
How To Store The Path Of Uploading File....
How we can store the acual path of uploading file. I want to store the path of file in my database but I am not getting anyway to implement that......if I try to do it with the name="filename" ... I mean if echo filename it only print or gives the filename only...it does not...
Inserting Uploaded File Path Into Database
When you upload a file, it automatically creates a varibale called File Type Name (in my example, its called USERFILE)_ Name (i.e. userfile_name). I thought that this variable held the path of the file selected, and if so, when I do my insert statement, couldnt i simply say this: $db = odbc_connect("2001Counsell" ,"",""); odbc_exec ($db, "INSERT INTO tblAssignment (Comments, AssignmentPath) VALUES ('$frmComments', '$userfile_name')"); That would then place the Path of the selected file into the appropriate field (AssignmentPath --> Text Field) in the database.
Trouble Getting Full Path To Client File
using php 4.2.0 on xp and writing a simple uploader. using $_FILES["name"] was expecting the full path to stick through basename(), but its only returning the already trimmed path. How d'ya get the full path using $_FILES...?
Function Popen And Spaces In The Path Or File Name
Have a problem with spaces in the function popen Next example works fine: .... $drive="c:"; $path=""; $file=" myfile.exe">"; $call = $drive.$path.$file; pclose(popen('start /b '.($call).'', 'r')); ..... Using "Program Files" in the path name $path=" Program"> Files"; (error: "c:Program ... " not found) or $path=" Program Files">"; (error: "c:Program%20Files ... " not found)
Getting The File Path From A Html Form Input
I want to get the file path from a file input field, not just the filename. I don't have to necesarily use the input of type 'file', but that is the only way i know how to have a browse button.I tried using javascript to fetch the content of the file with this function: function GetDirectory(){ strFile = document.FileForm.filename.value; intPos = strFile.lastIndexOf(""); strDirectory = strFile.substring(0, intPos); alert(strDirectory);} but i don't know how to pass the javascript variable to the php.
Store Upload File Path (Database)
I have come up with the following code, that uploads gif images to the server. How do I allow only MP3 files to be uploaded, and also store the path of the image in a database? Code:
Error :: Unable To Open 'file Path' For Writing
I have been working on this code for 2 days now and while progressing have encountered this error: Warning: imagejpeg() [function.imagejpeg]: Unable to open 'C:/web/root/images/thumbs/' for writing in C:web ootdevfilesadditemresize.php on line 40 here is code for the file outputting the error i have noted line 40 so you can spot it easily: Also the value of $GLOBALS['thumbpath'] is : 'C:/web/root/images/thumbs/' .....
Getting The Remote File Path From <input Type="file">
I'm using a form to upload a file to save in a mySQL database, however I need to store the original file path on the clients (the user uploading the file) computer. The file path is shown in the field that selects the file, I just need to post it or save it in a session somehow.
How To Find Full Path Of A File Upload Field In A Form?
I need a way to find the full path of a file uploaded by file upload form box. $_FILES['file1']['name'] gives just file name. I have a file upload form and if the user submitted something wrong I want the page to go back and have the forms maintain its values (the full path to local file, e.g: "c:/docs/landscape.jpg"). Any way to do that? This is a more complex applications so using another upload tool is not an option.
Relative Path / Absolute Path
What is the best way to resolve paths within a document regardless of what path it is opened under? For example: I have x.php and it contains <img src="images...">, (amongst other things, like php code), which resolves the correct image path when opened under / but when x.php is read into a file under /dir the image no longer resolves, for obvious reasons. With absolute paths, this isn't an issue but it is with relative paths. Although I can think of a kludge, or two, I figure that there is a more elegant solution.
Displaying Modified Date Of A URL File
I want to display a web page with links to various documents and display the date each document was last modified next to the link. I've found the filemtime command and that works quite nicely for "local" files. However, filemtime doesn't work if the file(s) are refered to by their URLs (which is how I need to do it). A comment on the manual page (http://www.php.net/manual/function.filemtime.php3) refers to having to use "Socket Operations" but the link posted with that comment doesn't work (it just goes to a page saying the website has been rearranged).
Displaying Text With Include File.
Given this html code page; ======begin <html> <body> <!--#include file="outing.1.shtml"--> <form action="form.php" method="GET"> <input type="hidden" name="op" value="ds"> <table width="468" border="0" cellspacing="0" cellpadding="0"> <tr> <input type="hidden" name="id[1]" value="1"> <td>Name<input name="name[1]" type="text" size="30"></td> <td>Email<input name="email[1]" type="text" size="60"></td> <td>Phone<input name="phone[1]" type="text" size="15"></td> </tr> </table> <input type="submit" name="submit" value="submit"> </form> </body> </html> ===========end and this php code page; ==========begin form.php <?php if($_GET["op"] == "ds") { foreach ($_GET["name"] as $key=>$value) { echo $_GET["name"][$key] ."-". $_GET["email"][$key] ."-". $_GET["phone"][$key] ."-". $_GET["id"][$key]; $fp=fopen("outing.1.shtml","a"); fwrite($fp,$_GET["name"][$key] ."-". $_GET["email"][$key] ."-". $_GET["phone"][$key]); fclose($fp); } } ?> ========end Both of these are on my IP server, EV1. I would like the contents of 'outing.1.shtml' to be displayed hence the <!--#include file="outing.1.shtml"--in the HTML code.
Displaying Contents Of A Text File?
I'm trying grab the content of a text file and print it a web page. I believe that I should be using something along the lines of "file" or "fopen", but I'm not having any luck. Any thoughts or tips?
Text File Displaying On Screen
I have a file that downloaded a CSV file for the user based upon some information gathered from the Database. My file was working fine until recently (I believe that my hosting company did something when they upgraded to PHP5). Everytime a user tries to download the file, it displays the contents on the screen. Here is what I have for my file handling. Am I missing anything obvious? when called, $filecontent is displayed to the screen... $downloadfile=$shownic."AttendeeRoster".time().".csv"; header("Content-disposition: attachment; filename=$downloadfile"); header("Content-type: text/css; charset=UTF-8"); header("Content-Transfer-Encoding: binary"); header("Content-Length: ".strlen($filecontent)); header("Pragma: no-cache"); header("Expires: 0"); echo $filecontent;
Displaying Data From A Flat File?
ive got a flatfile database sorted out, all i need now is how to store individual flat files per user and how to paginate that data. Just to make sure i'm doing everything right, i'll post the code below Code:
Wierd Characters When Displaying Content Of File
I have a txt file and when I display the content using echo some lines display correctly and some have wierd characters in between letters: for example: <?php echo $lines[1]; echo $lines[2]; as a result I am getting correctly displayed first line: 1st line: Product A 2nd line: between each letter there is a square P(square)r(square)o(square)d(square) etc. What should I do to display it correctly and why is it doing that?
Path To Php
Is there any way (on Windows) to determine, from within php, the directory that it is running from? In other words, what is the path to PHP? This particularly concerns the CLI php versions. On Linux, it has been suggested to do: which php but even this wouldn't help me since that would just show A php on the include path and not necessarily the currently executing instance. Also, getcwd() at startup only shows the path that php was started from and __FILE__ and phpinfo() do not offer this info either.
Set Path In *nix
I need to be able to set the command path from PHP on any *nix system, any shell. I know there are different formats depending on the shell; when I do a getenv(), it shows the colon-delimited format, but when I try to change it with putenv(), it's ignored, no matter what format I use, or even if I give it just a single path.
Path
I'm not sure if this is actually a PHP problem but I'm creating a web tool using PHP and am having probs. I've got a script which runs fine in command line but not on the web page. I think the problem is that when it is run externally the path info is not there and it doesn't know where to find the actual program that is then supposed to be run (from within the script). Is there a way of setting the PATH at the top of the script?
How To Do Correct Path?
I have many folders and subfolders on server. As I would like to add code on each page to detect server URL, I need help with this. Code is: $_PATH1="http://" . $_SERVER['HTTP_HOST']."/"; Why I have to add on link for images also / that it will work as it is already there / in Link is like. <img src="<?=$_PATH1?>images/myimage.jpg" ></a>
Path Function?
I'm reading the php manual to find out how to get the path of a file I'm uploading from my PC - I'm using the $_FILES[FileToUpload][name] var but that is just the filename - is there a function that I can use to get it's full path too? or is it by the time php gets it it's on the server so it's too late to worry about it? do I have to get into javascript to get the path on the PC side??? I'm trying to check the filesize before having to upload the file to the server only to find out it's too big for the limit I'm setting...
GetURL Path
Using PHP I want to REQUEST_URI (I think this is the best way forward - please correct me if I am wrong) then use something similar to subString to get the first directory from the URI string i.e. http://www.example.com/THIS_DIRECTORY/ use this value to get our current location and display an image. So if we are in ABOUT directory we would display an image further down in the HTML in relation to our ABOUT PAGE.
Include () Path
I created a homepage which use the include function. I am having problem with the path for image and link. here is my situation: Page Intro.php will call 3 other include which is Header.php, Body.php and Footer.php. All 3 files will use images from c: /images folder. When i create a new page (lets say Report.php which also used the same image from c:images) which i saved in C:Report the images from c:Images cannot be loaded and all the link are wrong. If there are any link(lets say link to Intro.php in c:) the link will be like this URL The only way that i found to resolve this problem are : to make another copy of C:Images and then put it in c:Report as for the link i have to type in URL to make it work.
Path Syntax
I know that a dot (".") stands for the current directory, two dots ("..") stand for the parent directory, but could someone please explain to me what ".:" stands for?
Checking Path.
I have a script that allows the user to open a file in the server and show it, this is so new files can be published without having to modify the script. What I want to check is that the file requested is not outside the path so they can't access other files in the system. let's supose all the files are in: $COMUNET_ROOT/../public_files/ and the file is $page so I wrote this: PHP Code:
Path Problems!
Im totally desperated with that issue :( I have a script called generate.php which opens a file and write in some datas : $fp = fopen("index.php", "w"); fputs($fp, $some_datas); fclose($fp); both of these files are in a subfolder : scripts/generate.php scripts/index.php If I run generate.php from its folder its not a problem but If I include it to a file in my root folder then the script looks for the root/index.php :( Ok it's easy to do fopen("scripts/index.php","w"); but then in my file generate.php I include it from several places on my site so I never know where it will be called. How to make sure it always opens the scripts/index.php ? I tried using fopen("http://www.mydomain.com/scripts/index.php","w"); but it doesnt work :(
Path Of A Server
I have mysql, php and apache installed on this comp. i ran into a php file that asks for a path to it's admin section. i have no idea what it is?
Get Cookie Of A Specified Path
how do you get cookie of a specified path in PHP? it seems there is no function in PHP which can retreive the cookie from a specified path. eg, a cookie named "ABC" of value "123" stored on a path "/hello/abc.html" how do I retreive the cookie "ABC" when I at the path "/morning/test.php" ?
Generating Path?
im trying to generate a path from a url. url is like test.php?f1=bong&f2=dong $secure = "c: ralalasomething"; $fo1 = 1; $t = 2; for($i = 1;$i <= $t; $fo1++, $i++) { $fo2 = $fo2 . "$f$fo1";} echo $secure . $fo2; this prints out c:ralalasomething$f1$f2 but i want it to print c:ralalasomethingongdong
Path To Includes
I can't seem to get the path to my include files right. The php app sits in /var/www/html/myapp. I have my include files in /var/www/includes. I've tried every configuration of relative paths to get to them, but nothing works. So I tried the absolute path like this include("/var/www/includes/HtmlFooter.txt") and that doesn't work. I've opened up the permissions all the way on the path and file, but still no luck. I even tried putting the files in "/usr/lib/myapp" and I still can't access them.
|