absolute-path

NodeJS - convert relative path to absolute

≯℡__Kan透↙ 提交于 2020-01-10 09:05:34
问题 In my File-system my working directory is here: C:\temp\a\b\c\d and under b\bb there's file: tmp.txt C:\temp\a\b\bb\tmp.txt If I want to go to this file from my working directory, I'll use this path: "../../bb/tmp.txt" In case the file is not exist I want to log the full path and tell the user: "The file C:\temp\a\b\bb\tmp.txt is not exist" . My question: I need some function that convert the relative path: "../../bb/tmp.txt" to absolute: "C:\temp\a\b\bb\tmp.txt" In my code it should be like

PHP: Translate relative img src urls to absolute

空扰寡人 提交于 2020-01-02 09:54:07
问题 I have fetched an HTML page using cURL into a string and loaded it up in a DOMDocument. There I can get all the img tags and their source attributes. My problem now is... how can I make these URLs absolute? The list of URLs can contain all kinds of variants, for example: foobar.jpg http://example.com/foobar.jpg /foobar.jpg ../foobar.jpg folder/foobar.jpg If the HTML is fetched from an arbitrary URL, what is a safe way of converting these image URLs into absolute ones? Is there a way you can

Getting an anchor element's absolute URL with jQuery

旧时模样 提交于 2020-01-01 08:13:08
问题 Given an anchor element (with something like $("a:first") ), how do you get the absolute URL that the anchor points to? 回答1: If you're using jQuery 1.6+, you can use .prop() : $("a:first").prop("href") Prior to 1.6, you can access the href property directly on the DOM element: $("a:first")[0].href; 回答2: to get the URL attached you can do something like... var url = $("a:first").attr('href'); this will give you the URL but doesnt guarantee absolute or relative. To find the absolute URL you can

Changing C# .dll references from absolute to relative

寵の児 提交于 2020-01-01 04:13:25
问题 I have compiled my project and some of my project's added .dlls have absolute references. When I try to run my project on another machine, it looks for the .dlls from the original project path. How can I make the project look for the .dlls using a relative path? 回答1: Edit the .csproj file and change the <HintPath> elements from absolute paths to relative paths. 回答2: You may also write your handler for resolving assemblies. In the simplest form it may look like this: AppDomain.CurrentDomain

get absolute path to apache webcontents folder from a java class file [duplicate]

谁说胖子不能爱 提交于 2020-01-01 02:40:15
问题 This question already has answers here : Recommended way to save uploaded files in a servlet application (2 answers) Closed 3 years ago . Need to get absolute path in java class file, inside a dynamic web application... Actually i need to get path of apache webapps folder... where the webapps are deployed e.g. /apache-root/webapps/my-deployed-app/WebContent/images/imagetosave.jpg Need to get this in a java class file, not on jsp page or any view page... any ideas? 回答1: Actually i need to get

Superagent with absolute url prefix

送分小仙女□ 提交于 2019-12-25 05:51:08
问题 I've noticed that I'm writing http://localhost everytime I want to run a node test with superagent. import superagent from 'superagent'; const request = superagent.agent(); request .get('http://localhost/whatever') .end((err, res) => { ... }); Is there any way of avoiding the localhost part? As far as I've gone is to avoid the request being hardcoded to the host: const baseUrl = 'http://localhost:3030'; request .get(`${baseUrl}/whatever`) But I still have to carry the baseUrl with the agent

PHP: Variable not accessible defined in include/require file using absolute path

时光毁灭记忆、已成空白 提交于 2019-12-25 04:25:02
问题 I am finding difficulty in accessing a variable defined in the include file. My include file is present in the root and it has a variable $x : localhost/dir_name/include.php I am including the include.php file in file.php present in the sub directory : localhost/dir_name/sub_directory/file.php But every time, the file.php gives the error of undefined variable $x The weird thing is that when I use a relative path to include the include.php , it works perfectly. Like this: include '../include

Get the absolute path of a file to be uploaded

旧街凉风 提交于 2019-12-24 06:31:40
问题 I am uploading a file using a simple FileUpload control named theFile (ASP.NET). I'm trying to get the absolute path of the file, but thefile.PostedFile.FileName and thefile.FileName are the exact same, just the file name, no path! I can't use Server.MapPath because I will be saving this file on a different server (transferring via byte array through a webservice). It breaks at this line: Dim fStream As New FileStream(thefile.FileName, FileMode.Open, FileAccess.Read) because it is taking the

MSBuild clean directory string

守給你的承諾、 提交于 2019-12-24 00:53:45
问题 I have a property in MSBuild to represent the directory above the MSBuildProjectDirectory: <PropertyGroup> <BuildDir>$(MSBuildProjectDirectory)\..</PRSBuildDir> </PropertyGroup> I need to then use this property, but I need the directory string cleaned so that it doesn't include the .. . In other words I need the .. evaluated, so that if the current project file is in C:\Test\Tom\MyDir , then I need a property containing the string C:\Test\Tom . The reason I'm asking is because I'm trying to

Getting relative path from absolute path in PowerShell

梦想与她 提交于 2019-12-24 00:19:51
问题 The problem You have an absolute path, but you want it to be relative to another path. Example: P:/SO/data/database.txt --> Now we want the filename to be relative to: P:/SO/team/lists/ ../../data/database.txt I have already found the Stack Overflow question How to convert absolute path to relative path in PowerShell? . One answer links to an already developed Cmdlet, but this one didn't work for me. And the trick using Set/Get-Location requires the paths to exist. 回答1: The solution I found