urlencode

php - file_get_contents - Downloading files with spaces in the filename not working

天涯浪子 提交于 2019-12-18 04:53:27
问题 I am trying to download files using file_get_contents() function. However if the location of the file is http://www.example.com/some name.jpg , the function fails to download this. But if the URL is given as http://www.example.com/some%20name.jpg , the same gets downloaded. I tried rawurlencode() but this coverts all the characters in the URL and the download fails again. Can someone please suggest a solution for this? 回答1: I think this will work for you: function file_url($url){ $parts =

How to URL encode periods?

喜夏-厌秋 提交于 2019-12-18 03:49:19
问题 I need to URL encode some periods since I have to pass some document path along and it is like this http://example.com/test.aspx?document=test.docx So test.docx is causing me an error of an illegal character. So I need to change it to . --> %2E I tried to use Server.UrlEncode string b = Server.UrlEncode("http://example.com/test.aspx?document=test.docx"); but I get "http%3a%2f%2fexample.com%2ftest.aspx%3fdocument%3dtest.docx" So do I have to use like a string replace and do it manually and

How to leave URL parameters unescaped in ASP.NET MVC?

懵懂的女人 提交于 2019-12-18 03:40:02
问题 I've noticed the returnurl URL parameter on the Stackoverflow login/logout links are not escaped but when I try to add path as a parameter to a route it gets escaped. So /login?returnurl=/questions/ask shows /login?returnurl=%2fquestions%2fask and it's kind of ugly. How do I get it to not escape the returnurl value? Here's what I'm doing in the code: Html.ActionLink("Login", "Login", "Account", new { returnurl=Request.Path }, null) 回答1: How do I get it to not escape the returnurl value How's

urlencode a multidimensional dictionary in python

被刻印的时光 ゝ 提交于 2019-12-17 22:57:00
问题 How can I get a URL-encoded version of a multidimensional dictionary in Python? Unfortunately, urllib.urlencode() only works in a single dimension. I would need a version capable of recursively encoding the dictionary. For example, if I have the following dictionary: {'a': 'b', 'c': {'d': 'e'}} I want to obtain the following string: a=b&c[d]=e 回答1: OK people. I implemented it myself: import urllib def recursive_urlencode(d): """URL-encode a multidimensional dictionary. >>> data = {'a': 'b&c',

Java URL encoding: URLEncoder vs. URI

岁酱吖の 提交于 2019-12-17 21:52:40
问题 Looking on the W3 Schools URL encoding webpage, it says that @ should be encoded as %40 , and that space should be encoded as %20 . I've tried both URLEncoder and URI , but neither does the above properly: import java.net.URI; import java.net.URLEncoder; public class Test { public static void main(String[] args) throws Exception { // Prints me%40home.com (CORRECT) System.out.println(URLEncoder.encode("me@home.com", "UTF-8")); // Prints Email+Address (WRONG: Should be Email%20Address) System

how to insert %20 in place of space in android

旧街凉风 提交于 2019-12-17 18:33:08
问题 I have a xml URL file in which there are white spaces i want to replace white spaces with %20.. how to do this???? SAXParserFactory spf = SAXParserFactory.newInstance(); SAXParser sp = spf.newSAXParser(); XMLReader xr = sp.getXMLReader(); /** Send URL to parse XML Tags */ URL sourceUrl = new URL( "http://www.arteonline.mobi/iphone/output.php?gallery=MALBA%20-%20MUSEO%20DE%20ARTE%20LATINOAMERICANO%20DE%20BUENOS%20AIRES"); XMLHandlerartistspace myXMLHandler = new XMLHandlerartistspace(); xr

http_build_query() without url encoding

送分小仙女□ 提交于 2019-12-17 18:32:48
问题 Is there a way to use http_build_query() without having it URL encode according to some RFC standard? Why I don't want to URL encode everything: I'm querying the Ebay API.. They honestly insist on parameter names not being URL encoded, as far as commas in parentheses. E.g. DomainName(0) is a parameter, and the query fails if those parens are encoded. 回答1: You can use urldecode() function on a result string which you get from http_build_query() 回答2: Nope, it appears to always want to encode

How to URL encode parameters in ASP .NET MVC

不打扰是莪最后的温柔 提交于 2019-12-17 14:47:41
问题 I have the following code in my view: <%= Html.ActionLink( "View item", "Index", "Items", new { itemName = Model.ItemName }, null) %> I have a problem when the item name contains a sharp (#) or the percent symbol (%). When the item name is "name#with#sharp#" , the controller receives only the first part of the name until the first sharp (only receives "name" ). When the item name is "name%with%percent" I get an error: HTTP error 400 - Bad request. I not sure if this is a problem with the URL

String won't url encode in iOS

浪子不回头ぞ 提交于 2019-12-17 12:30:12
问题 I'm seriously having a brain fart here, but I can't figure out why this isn't encoding for the life of me. Been searching all over, and I can't even get the code samples to encode. Any ideas? NSString *searchString = @"waffl&es"; NSString *encodedSearchString = [searchString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; NSString *urlString = [NSString stringWithFormat:@"http://en.wikipedia.org/?search=%@", encodedSearchString]; NSURL *url = [NSURL URLWithString:urlString];

Pass a percent (%) sign in a url and get exact value of it using php

泄露秘密 提交于 2019-12-17 10:58:25
问题 I am trying to pass percent (%) sign in url like %B6011000995504101^SB but when I echo, it returns ♦011000995504101^SB I want exact same value as I pass it in URL. I have tried to use urlencode() function, but it give me output like this... %B6011000995504101%5ESB please help me regarding this 回答1: Answer: To send a % sign in a url, instead send %25 . In your case, in order for php to see a percent sign, you must pass the character string %25B6011000995504101^SB to the server. Why: In URLs,