...

View Full Version : upload error



boeing747fp
01-18-2004, 02:53 AM
This Code keeps giving me this:
-------
Possible file upload attack! Here's some debugging info:
Array
(
[file] => Array
(
[name] => opportunity_small.jpg
[type] => image/pjpeg
[tmp_name] => /tmp/php9AuCP2
[error] => 0
[size] => 19071
)
)

-----------------Here's the code---------------

<?php
$uploaddir = '/www/art/';
$uploadfile = $uploaddir . $_FILES['file']['name'];

print "<pre>";
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
print "Large Image File is valid, and was successfully uploaded. ";
print "Here's some more debugging info:\n";
print_r($_FILES);
} else {
print "Possible file upload attack! Here's some debugging info:\n";
print_r($_FILES);
}
print "</pre>";

firepages
01-18-2004, 03:51 AM
possibly ..

$uploadfile = $uploaddir . $_FILES['file']['name'];

should be

$uploadfile = $uploaddir . $_FILES['userfile']['name'];

boeing747fp
01-18-2004, 03:52 AM
nope

firepages
01-18-2004, 04:01 AM
;) well I still think thats wrong but anyway ..

have you given '/www/art/' the appropriate file permissions ? , I dont see what else could be wrong...

(temporarily) try changing move_uploaded_file() for copy() , you may get a more useful error message.

Note that move_uploaded_file() should itself print a reason it did not work perhaps error_reporting is too high.. add

error_reporting(E_ALL);

to the top of your script whilst testing.

boeing747fp
01-18-2004, 04:03 AM
this code came right off from php.net, but i changed the directories... that's it

boeing747fp
01-18-2004, 04:23 AM
i added error_reporting(E_ALL); and got this now:
Warning: copy(http://narrowwaystudio.com/public_html/art/): failed to open stream: HTTP wrapper does not support writeable connections. in /home/narrow/public_html/admin/upload2.php on line 6

firepages
01-18-2004, 04:37 AM
ok, make

$uploaddir = $_SERVER['DOCUMENT_ROOT'] . '/art/';

(thats assuming www is part of your doc root and not a folder you have created)

which should translate to ...
'/home/$username/public_html/art/'; or similar

boeing747fp
01-18-2004, 04:41 AM
still same error

firepages
01-18-2004, 04:54 AM
ok 1st off what is the name of the <input type="file" name="$whats_this" ..

ou are using both $_FILE['file'] and $_FILES['infile'] which makes no sense unless you are uploading mulltiple images ...


anyway if this does not work then give up ;) (changinf 'file' for 'infile' if required;

just this & nothing else.


<?
move_uploaded_file( $_FILES['file']['tmp_name'] , $_SERVER['DOCUMENT_ROOT'] . '/art/' . $_FILES['file']['name'] ) ;
?>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum