Unable to access files in subfolders
Hi,
I am writing a javascript to select a random image from several images, which I have categorized and put in sub folders, these sub folders are in another folder "img" .
So when i try to access a file "file1" , i use "./resources/img/folder1/file1" to access it.
This works fine when i do a preview of the page. But when I publish the site, the file cannot be accessed and nothing shows up on my page.
Also if I try to access a particular file in the resources folder using the full url http://mysite/resources/file through a browser, it opens. But, if i try to access the same in the "img" folder using http://mysite/resources/img/file, it throws the 404 not found error.
I dont see any problem with my script as it can access the files in resources folder itself. Is there any access privilege issue here?
Thanks
kracksmack
I am writing a javascript to select a random image from several images, which I have categorized and put in sub folders, these sub folders are in another folder "img" .
So when i try to access a file "file1" , i use "./resources/img/folder1/file1" to access it.
This works fine when i do a preview of the page. But when I publish the site, the file cannot be accessed and nothing shows up on my page.
Also if I try to access a particular file in the resources folder using the full url http://mysite/resources/file through a browser, it opens. But, if i try to access the same in the "img" folder using http://mysite/resources/img/file, it throws the 404 not found error.
I dont see any problem with my script as it can access the files in resources folder itself. Is there any access privilege issue here?
Thanks
kracksmack
1
person has this question
I have this question, too!
Tell me when someone answers.
The more people who ask this question, the more it gets noticed.
The more people who ask this question, the more it gets noticed.
-
Inappropriate?Hi,
Can I take a look at the string of code you are using? Is it an img src tag? If you could paste it in here that would be great, please wrap it in <!-- at the beginning and --> at the end.
Here is an example that I just created using your scenario:
<!--
<img src="http://blogemmy.synthasite.com/resources/img/natural_health.jpg">
-->
Thanks,
Emmy -
Inappropriate?Here is my script . It works fine when I do a preview with sitebuilder but it doesnt work when i publish it.
<!--
<script language="JAVASCRIPT">
function lifetimer(){
BirthDay = new Date(document.live.bday.value);
var Year = BirthDay.getFullYear();
var Month = BirthDay.getMonth()+1;
var Day = BirthDay.getDate();
var sDay = "";
var sMonth = "";
var cStartDate = new Date('11/18/1985');
var cEndDate = new Date('12/31/1995');
if((BirthDay < cStartDate) || (BirthDay >cEndDate)){
Day = 1 + Math.floor((Math.random()*10000) % 27);
Month = 1 + Math.floor((Math.random()*10000) % 12);
Year = 1986 + Math.floor((Math.random()*10000) % 10);
}
if(Day < 10){
sDay = sDay + "0"+ Day;
}
else{
sDay = sDay + Day;
}
if(Month < 10){
sMonth = sMonth + "0"+ Month;
} else{
sMonth = sMonth + Month;
}
image = "./resources/img/" + Year + "/" + sMonth + "/" + Year + "" + sMonth + "" + sDay + ".gif";
document.live.bdayImage.setAttribute("src", image);
}
</script>
-->
I’m anxious
-
Hi kracksmack
When you write your site's url, trying doing it one of two ways:
1. http://YOURSITE'SURL/resources/img/folder1/file1
or
2.http://resources/img/folder1/file1
I also wonder if maybe you need to replace "img" with another name? Perhaps this is too confusing for the code to work?? I have no idea if this basis is true though. -
Hey littleus thanks for jumping in here! I did test using img as a folder name originally thinking that was the problem, but was able to make my string of code above work calling an image from a folder with that name. Looking at your code kracksmack, I am wondering where the image names are that are being called? Is that the full code that you are using on your page that you said is rendering in preview but not published? -
Inappropriate?well the files are stored like this resources/img/year/month/yearmonthday.gif , so the "image" variable in that script holds the image location. I have this form named "live" where am supposed to show this image. The problem is the script runs perfectly if i use sitebuilder preview and doesnt work if I published it. If something was wrong with my script it wouldnt have worked with preview either.
This is the html that calls the javascript
<!--
<form id="live" name="live">
<center>
Please enter your Birth date::<input id="bday" name="bday" value="" size="10" type="text"> Example: (mm/dd/yyyy)
<input name="start" value="Get it!" onclick="lifetimer()" type="button">
<p></p>
<img id="bdayImage" name="bdayImage" src="">
</center>
</form>
-->
I’m frustrated
-
You said "The problem is the script runs perfectly if i use sitebuilder preview and doesnt work if I published it. If something was wrong with my script it wouldnt have worked with preview either."
This has happened to me before too and it was some little typo that I did that caused it not to work in the published mode but you could see it in the preview mode. For me, the typo was putting the " after the >, instead of before the >. The image still rendered in the preview mode but would not work at all in the published mode. I wonder if this might be the case for you as it would appear that Emmy was able to make the script work for her?
Would you mind sharing your url? Perhaps fresh eyes may be able to see if there's something amiss? -
Inappropriate?I sure can use an extra pair of eyes, I have been trying to get this thing running from yesterday!
http://chquotes.synthasite.com/bdaych...
Thanks!
I’m thankful
-
Inappropriate?I just tried the bday thing, and a broken image showed up. Not sure what would cause this, it looks like your code should work.
-
IE explicitly shows a broken image when the page is loaded. But if this problem is fixed , I can make it invisible and hide it from the user until he clicks the button
Thanks for trying though. -
kracksmack.. here's a thought... are you IE or FF? Trying implementing your code using the other browser and see if that makes any difference. I'll try to take a look at your url now to see if I can spot anything. -
Inappropriate?I have tried it using Chrome. I would try it in FF by for some reason it doesn't want to open correctly. Sorry I can't be much more of a help.
-
Inappropriate?What exactly are you looking for this to do? You enter in your birth date, then what is supposed to happen?
-
Enter your birthdate and it will get the Calvin and Hobbes Strips released on the day you were born. Now since my files are named and categorized by year month and day i just constructed the string which refers to the location using the birthdate. Incase the birthdate is invalid, I just get a random date which will be valid( that is there will be a corresponding file) and use that instead.
Thanks
kracksmack -
Inappropriate?No worries lambofgod. I guess there is some problem other than my script, because I tried to access files using full url and it doesn't work (404 not found) but if i try something which is in resources folder, I can access it directly through the browser.
-
Inappropriate?Hi kracksmack
Could you please post the location where you found this feature that you are trying to use. This would simplify helping you with your coding... -
I gathered bits of it from here and there, but I wrote it myself. -
Inappropriate?I have the same thing. I used to have /resources/images/img.gif or something but it never worked. So I have everything like /resources/img.gif
could this possibly be the Site Builder? Like could it be a small bug? -
Thats what am guessing..but I really don't want to put all my files into the resources folder, its already crowded. -
Inappropriate?kracksmack - when I look at your code, it would appear to me that you are not using your full image url? The link you gave me - is that your preview site or your published site? I'd like to see the difference if possible.
-
Inappropriate?Its published one
If you want to look at the preview here is the link
http://sitebuilder.yola.com/sites/Dab...
Not sure if it will work without authentication -
Inappropriate?I have made a page with the four ways to post an image:
http://testpage2.synthasite.com/image...
which one(s) works for you guys?
*all of them are of the same image -
did you use the image widget? -
Inappropriate?Wait, is the last one posted the site preview?
-
If you are referring to the sitebuilder. blah blah .. yes thats the preview link -
Inappropriate?Hey kracksmack
Try removing the period before the back slash in the URLs...
image = "./resources/img/" + Year + "/" + sMonth + "/" + Year + "" + sMonth + "" + sDay + ".gif";
//document.write(image);
//image = "./resources/19901008.gif";
document.live.bdayImage.setAttribute("src", image);
TO
image = "/resources/img/" + Year + "/" + sMonth + "/" + Year + "" + sMonth + "" + sDay + ".gif";
//document.write(image);
//image = "/resources/19901008.gif";
document.live.bdayImage.setAttribute("src", image); -
No use, I tried that already -
Inappropriate?Can you please post the URL to your published site?
-
-
Inappropriate?OK I see it above
sec and I will try something... -
Inappropriate?Regardless the periods are not meant to be there and they will mess up the code to that file so I would leave it out.
Hmmm I have tried the last image URL and the image is not there so that might be a contributing factor. resources/19901008.gif
http://chquotes.synthasite.com/resour...
As well double check all your back slashes and addition signs are correct in the date calculation part of your code. Something looks a little odd there. I wonder why there needs to be one (+) before and one after? hmmm
I have an important project I am missing out on right now or I would spend all day on this... Sorry I have a deadline... :(
I will give it a try tomorrow if I have the time.
E -
Thanks for trying.
The line which refers to 19901008.gif is commented out.
I copied the image from the img folder into resource folder to see if it there is some file access privilege setting for the files and the strangest thing is that file is not accessible. So am thinking that there is something messed up with file permissions.
Don't know if it matters but I uploaded zip files to img folder and then unzipped them using the file manager. -
Inappropriate?Sorry but had to get some shut eye before by big competition today. Took home 2nd place :)! Anyways, I just tried it with your published site and it work perfectly. I used 02/11/1983. And it came up with them talking about the kids mom having another baby. I think it might be working.
-
Thanks for looking at it again. But I had to delete all my folders, upload all my files few at a time into the resources directory. Took about 4 hours to do that! I bet mine will be the most crowded resources directory on yola :P
Loading Profile...




EMPLOYEE

CHAMP