- Home /
using WWW to download image from web. Not working on my own website, but does from other urls
Hi there
I have this script attached to a RawImage file in my games UI
public class DownloadImage : MonoBehaviour {
string url = "http://megabrogames.rf.gd/pic.jpg";
//string url = "https://i.imgur.com/xBSyvRx.jpg";
IEnumerator Start () {
WWW www = new WWW(url);
yield return www;
GetComponent<RawImage>().texture = www.texture;
}
}
Both jpg files are the same. One I uploaded to Imgur , this works. The other is on my own website . The url to my website works fine, I have checked in on two computers and several browsers
All I get is the red question mark. But if I am to uncomment the other one instead it all works perfectly.
My problem is that I have hardcoded the url into the game, and I want to change the image each week. It has to be the same URL for that to work, but i think with Imgur it will auto assign whatever url it feels like.
thanks for any help
Answer by Larry-Dietz · Dec 22, 2017 at 01:17 AM
While I am not sure how to correct your problem, I do have some additional information that might point you in the right direction.
When trying to pull the image from your server, it is receiving the following response...
<html>
<head><title>403 Forbidden</title></head>
<body bgcolor="white">
<center><h1>403 Forbidden</h1></center>
<hr><center>nginx</center>
</body>
</html>
So I would guess that something in the configuration of your server is blocking the app from pulling the image.
I tried copying your image to my own server, and it worked fine from there.
May want to dig through your server configuration, and see if you can figure out why it is sending a forbidden response.
Hope this helps, -Larry
hi there , thanks for the information about Forbidden 403. I was getting that to start with when loading my image on the website in a web browser, but that seems to have gone. Additionally, I tried signing up 2 more domain names (megabrogames.co.uk and megabrogames.download) and each have different hostings , but I still have the problem with all of them :[
I will keep looking into it. I already asked the webhost live chat, but they said it was nothing to do with their service lol
@Larry-Dietz thanks very much for going as far as you did to check the pic. At least now I know for sure it is something to do with the websites hosts (i think lol)
Coz all the permissions have been triple checked its 755 for folders, and 644 for files. I dont know really what else I can do, except maybe host my own ftp server or something
Are you using free hosting? I find that they can often be pretty restrictive. A lot of them block hot linking. I can tell you that my server is hosted by GoDaddy, and it was able to serve your image without any issues, into the RawImage UI component.
Answer by megabrobro · Dec 22, 2017 at 04:38 PM
It appears it was the free hosting blocking the linking of images.
My workaround for free (I dont want to pay a monthly fee of any kind for this hobby project) was to open an account with Github pages. They let me manage a website on their domain including the file names and it was very easy. It now all works.
Thanks for your help Larry
You are very welcome. I am glad you found a solution to this :)
-Larry
Your answer
Follow this Question
Related Questions
Download pdf file form url and saving in the specific folder in the mobile. 2 Answers
Video Player URL Stream Dropbox Video in Android Has Bug, but works fine in editor 0 Answers
Unity Down grade safety 5.6.1->5.6.0 0 Answers
Is there a way to make DLC in unity without assetbundle? 0 Answers
MongoDB C# authentication exception 0 Answers