0

I almost done with pset6 but I need your help. When i type cat.jpg the image loads just fine. But, if i hit refresh, the path gets concatenated one additional time. Btw do not mind my comments, I have changed the code so many times so when it is all done i shall update the comments. an example is below:

   GET /cat.jpg HTTP/1.1
    request is:/cat.jpg
    query is:
    absolutepath is:/cat.jpg
    path is:/home/jharvard/Dropbox/Dropbox/CS50/pset6/public/cat.jpg
    Extension is:jpg
    HTTP/1.1 200 OK
    GET /cat.jpg HTTP/1.1
    request is:/cat.jpg
    query is:
    absolutepath is:/cat.jpg
    path is:/home/jharvard/Dropbox/Dropbox/CS50/pset6/public/cat.jpg/cat.jpg
    HTTP/1.1 404 Not Found

How do I stop this from happening.

Also when i load cat.html, the image won't load. I just see the icon! I have used chmod a+r cat.html from terminal within my public directory but still the thing wont load. An example is also below:

    GET /cat.html HTTP/1.1
    request is:/cat.html
    query is:
    absolutepath is:/cat.html
    path is:/home/jharvard/Dropbox/Dropbox/CS50/pset6/public/cat.html
    Extension is:html
    HTTP/1.1 200 OK
    GET /cat.jpg HTTP/1.1
    request is:/cat.jpg
    query is:
    absolutepath is:/cat.jpg
    path is:/home/jharvard/Dropbox/Dropbox/CS50/pset6/public/cat.html/cat.jpg
    HTTP/1.1 404 Not Found
2

I fixed it so never mind:

The answers is :

char* path = malloc(strlen(root) + strlen(absolute_path) +1);
strcpy(path,root);
strcat(path,absolute_path);

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .