Wednesday, August 03, 2005

substance

link: http://ranssite.gloriousrobot.com/collage/upload2.php

code:
http://ranssite.gloriousrobot.com/collage/code.jpg

sorry that it's an image, if there's a way to post html into this thing without it becoming embedded, i didn't figure it out

5 Comments:

At 12:41 PM, Blogger Nick Doty said...

Yeah, that is strange. I would expect it to spit out a very simple page saying "I am the walrus" rather than absolutely nothing when I upload a file. It might be that the script doesn't know to flush the output, though I can't duplicate that problem in my own scripts.

Does it send the output properly when you comment out the copy line? When you echo more content including a newline character (\n)?

Email me or come find me in the Mac lab if you'd like some help debugging (I may not be checking blogs very often).

 
At 9:16 AM, Blogger Alex Wales said...

the only way i know to post raw code is to

1) Find and replace <'s with &lt; ... and >'s with &gt;

2) then put it inside a <pre></pre>.

 
At 9:27 AM, Blogger Alex Wales said...

...and as to the code ... the script's not working for me, either. It looks to me that there's only one way to get blank content - namely, $_POST['submit'] is true but $userfile is empty. You could test that by putting something in an }else{ clause after your if($userfile ... Or, just, is the file actually uploading?

What happens if you directly reference $_POST['userfile'] instead of the $userfile that you declared as global?

 
At 10:57 AM, Blogger Nick Doty said...

Alex is quite right, I feel very silly for not having noticed it (I thought somehow the if $userfile portion was evaluating as true, so the problem couldn't be this, but of course it wasn't).

In most modern versions of PHP (the switch was 4.2), register_globals is set to 'off' by default. That means that every variable that you want to get out of POST, GET or COOKIE (or SERVER or whatever) data must be referred to as $_POST['variablename']. PHP will not automatically fill $variablename.

For more info:
http://www.php.net/register_globals

 
At 12:36 PM, Blogger Bryan Alexander said...

from my test just now:

"I am the walrus
Warning: copy(images/test.jpg): failed to open stream: Permission denied in /home/jgloriou/public_html/ranssite/collage/upload2.php on line 9"

 

Post a Comment

<< Home