PDA

View Full Version : upload files not working


aragorn_reborn
01-20-2007, 06:48 AM
I am creating a custom page on my vBulletin installation. The page will allow users to upload files. I am using the vBulletin system for the same. The code that i used for the same is given below. I get this error when i try to upload any file


Warning: move_uploaded_file(Uploads/index.html ): failed to open stream: No such file or directory in /usr/local/share/doc/vhost/mydomain.org/httpdocs/screen/index.php on line 84

Warning: move_uploaded_file(): Unable to move '/users/mydomain.org/tmp/phpsj0NMr' to 'Uploads/index.html ' in /usr/local/share/doc/vhost/mydomain.org/httpdocs/screen/index.php on line 84


Its not a directory permissions issue because the uploads work fine when i use a upload php script without using the vbulletin base. Here is the code i used.


if ($_REQUEST["do"] != "") {

$vbulletin->input->clean_array_gpc('f', array(
'attachfile' => TYPE_FILE
));

$target_path = "Uploads/";
$filename = $vbulletin->GPC['attachfile']['name'];
$target_path = $target_path . $filename;
if (move_uploaded_file($vbulletin->GPC['attachfile']['tmp_name'], $target_path))
{
//Yay! File Upload was successful
echo "File upload successful";
}


I am stuck with this for the last one week. Kindly help...

Thanks in advance.

There is a upload class in vBulletin. Is that of some help?

I have to use the interface to upload pdf files of upto 2 Mb.

calorie
01-20-2007, 07:46 AM
The error is saying that the Uploads directory is not in or writable to the screen directory. Try changing $target_path to the full server path and make sure the Uploads directory is writable.

aragorn_reborn
01-20-2007, 08:15 AM
Thanks. The problem was with the target address. Specifying the complete path worked.

You rock!!!