CrazeD
Member
+368|6938|Maine
I have a second PC here acting as a local home web server for development purposes. I have a very odd problem. When I use PHP upload scripts to upload images, I cannot view the image on my PC, but the images work fine in the websites and can be viewed on the server itself, but I cannot open the images from my PC. I get "image can not be displayed" or something on the default picture viewer thinger-jigger. Also, I tried to upload said images to my real website via FTP and got errors.

So, why is that? Anyone got any ideas?

Both PC's running XP.
signa
~~~~~
+50|6994|Michigan, USA
I had a similar problem with running a webserver on a 2nd pc.  I used a dyndns name, and whenever I tried to access the website from my main pc, it wouldn't work because the main pc was resolving the ip and then trying to connect to it, so it was like trying to connect to your wan ip.
I fixed that problem by editing my hosts file and manually pointing it to the lan ip:   mywebsite.com  192.168.100.1

another thought: it could be your apache conf file denying access from your main pc
or it could be a chmod problem - but I doubt it since your running xp.

I guess we need more info on how you are trying to access the picture when it gives you the "cannot be displayed" error...
CrazeD
Member
+368|6938|Maine
Well I have a folder shortcut that sends me to where the file is located.

"\\192.168.0.89\C:\WEB\public_html\blah\uploadedpic.jpg" for example.

I can access pictures if they were copied there and not uploaded, but I cannot access files that were specifically uploaded with a PHP script. Nothing fancy with the script, just your utter basic uploading script.
mikkel
Member
+383|6866
Check the file permissions. Make sure everyone's got read access.
CrazeD
Member
+368|6938|Maine

mikkel wrote:

Check the file permissions. Make sure everyone's got read access.
I do. Remember that everything is fine until I simply upload an image via PHP, it is then no longer accessible except by the server itself.

I suspect it's something to do with how PHP/Apache handles the file uploading.
signa
~~~~~
+50|6994|Michigan, USA
Well it definitely sounds like some sort of problem with access permissions in windows, especially if you say the images are displayed on the website properly, and you can view them in a web browser.

what php script are you using that is giving the problem?

CrazeD wrote:

Also, I tried to upload said images to my real website via FTP and got errors.

So, why is that? Anyone got any ideas?
make sure when your uploading by FTP your using "binary" transfer.
CrazeD
Member
+368|6938|Maine

signa wrote:

Well it definitely sounds like some sort of problem with access permissions in windows, especially if you say the images are displayed on the website properly, and you can view them in a web browser.

what php script are you using that is giving the problem?

CrazeD wrote:

Also, I tried to upload said images to my real website via FTP and got errors.

So, why is that? Anyone got any ideas?
make sure when your uploading by FTP your using "binary" transfer.
If I copy the images from the server box to my PC and then upload via FTP, or view them, they all work fine.

The upload script is just your basic upload script.

Code:

function uploadImage($path='',$image='')
{
    if (is_dir($path)) {
        if (is_uploaded_file ($image['tmp_name'])) {
        $imageName = $image['name'];

        move_uploaded_file ($image['tmp_name'], $path . $imageName);        

        return true;
        } else {
            return false;
        }
    } else {
        return false;
    }
}
Scorpion0x17
can detect anyone's visible post count...
+691|7031|Cambridge (UK)

CrazeD wrote:

signa wrote:

Well it definitely sounds like some sort of problem with access permissions in windows, especially if you say the images are displayed on the website properly, and you can view them in a web browser.

what php script are you using that is giving the problem?

CrazeD wrote:

Also, I tried to upload said images to my real website via FTP and got errors.

So, why is that? Anyone got any ideas?
make sure when your uploading by FTP your using "binary" transfer.
If I copy the images from the server box to my PC and then upload via FTP, or view them, they all work fine.

The upload script is just your basic upload script.

Code:

function uploadImage($path='',$image='')
{
    if (is_dir($path)) {
        if (is_uploaded_file ($image['tmp_name'])) {
        $imageName = $image['name'];

        move_uploaded_file ($image['tmp_name'], $path . $imageName);        

        return true;
        } else {
            return false;
        }
    } else {
        return false;
    }
}
Put in some debug echo's to check that your $path and $image variables contain the right information.

Also add some debug echo's that'll show the code path and return values.

Are you sure the code is doing what you think it is?

Last edited by Scorpion0x17 (2008-12-30 08:33:58)

CrazeD
Member
+368|6938|Maine

Scorpion0x17 wrote:

CrazeD wrote:

signa wrote:

Well it definitely sounds like some sort of problem with access permissions in windows, especially if you say the images are displayed on the website properly, and you can view them in a web browser.

what php script are you using that is giving the problem?


make sure when your uploading by FTP your using "binary" transfer.
If I copy the images from the server box to my PC and then upload via FTP, or view them, they all work fine.

The upload script is just your basic upload script.

Code:

function uploadImage($path='',$image='')
{
    if (is_dir($path)) {
        if (is_uploaded_file ($image['tmp_name'])) {
        $imageName = $image['name'];

        move_uploaded_file ($image['tmp_name'], $path . $imageName);        

        return true;
        } else {
            return false;
        }
    } else {
        return false;
    }
}
Put in some debug echo's to check that your $path and $image variables contain the right information.

Also add some debug echo's that'll show the code path and return values.

Are you sure the code is doing what you think it is?
I'm pretty sure the code is doing what I think it is, seeings it works.

It uploads the images fine, and puts them in the right directory fine. The images work fine on the website, and while using VNC on the server everything is normal. With the upload script on my real website, everything works fine...I can download images, view them, blah blah everything is fine.

The only problem is that I cannot view images from my PC by selecting them from the networked folder. I can see them fine on the website, but I cannot view them and cannot move them. I can move/view any other file on the server, except for uploaded images.

Is there some type of setting in the Apache config or php.ini that changes uploaded file privileges that I'm not aware of?
Scorpion0x17
can detect anyone's visible post count...
+691|7031|Cambridge (UK)

CrazeD wrote:

Scorpion0x17 wrote:

CrazeD wrote:


If I copy the images from the server box to my PC and then upload via FTP, or view them, they all work fine.

The upload script is just your basic upload script.

Code:

function uploadImage($path='',$image='')
{
    if (is_dir($path)) {
        if (is_uploaded_file ($image['tmp_name'])) {
        $imageName = $image['name'];

        move_uploaded_file ($image['tmp_name'], $path . $imageName);        

        return true;
        } else {
            return false;
        }
    } else {
        return false;
    }
}
Put in some debug echo's to check that your $path and $image variables contain the right information.

Also add some debug echo's that'll show the code path and return values.

Are you sure the code is doing what you think it is?
I'm pretty sure the code is doing what I think it is, seeings it works.

It uploads the images fine, and puts them in the right directory fine. The images work fine on the website, and while using VNC on the server everything is normal. With the upload script on my real website, everything works fine...I can download images, view them, blah blah everything is fine.

The only problem is that I cannot view images from my PC by selecting them from the networked folder. I can see them fine on the website, but I cannot view them and cannot move them. I can move/view any other file on the server, except for uploaded images.

Is there some type of setting in the Apache config or php.ini that changes uploaded file privileges that I'm not aware of?
Ah, sry... tbh, I cba to read the whole thread... so why were you posting the script, if it works???

anyhoo... nm... that's a weird one, what file privileges do the uploaded files, and the directory they're in, have?

Can you drag an image file, via the network, from your PC, to said directory?
CrazeD
Member
+368|6938|Maine

Scorpion0x17 wrote:

CrazeD wrote:

Scorpion0x17 wrote:

Put in some debug echo's to check that your $path and $image variables contain the right information.

Also add some debug echo's that'll show the code path and return values.

Are you sure the code is doing what you think it is?
I'm pretty sure the code is doing what I think it is, seeings it works.

It uploads the images fine, and puts them in the right directory fine. The images work fine on the website, and while using VNC on the server everything is normal. With the upload script on my real website, everything works fine...I can download images, view them, blah blah everything is fine.

The only problem is that I cannot view images from my PC by selecting them from the networked folder. I can see them fine on the website, but I cannot view them and cannot move them. I can move/view any other file on the server, except for uploaded images.

Is there some type of setting in the Apache config or php.ini that changes uploaded file privileges that I'm not aware of?
Ah, sry... tbh, I cba to read the whole thread... so why were you posting the script, if it works???

anyhoo... nm... that's a weird one, what file privileges do the uploaded files, and the directory they're in, have?

Can you drag an image file, via the network, from your PC, to said directory?
I posted the script because someone asked about it.

Now that you mention it, there is something funky about the file privileges.

This is from a file that was manually put in the directory:

https://i13.photobucket.com/albums/a283/crazed_rider/security.jpg

And this is an uploaded file:

https://i13.photobucket.com/albums/a283/crazed_rider/nosecurity.jpg

And this is the folder:

https://i13.photobucket.com/albums/a283/crazed_rider/folder.jpg

Is the fact that CREATOR OWNER has no privileges the reason? What is that and how do I change the permissions?

EDIT: On the second image, note the missing security tab. Why?

EDIT 2: Oh, and yes I can drag files, make files and make directories anywhere I want from my PC, no problems.

Last edited by CrazeD (2008-12-30 10:25:19)

Board footer

Privacy Policy - © 2025 Jeff Minard