Need urgent reply for move_uploaded_file function

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
sivakumari
Forum Newbie
Posts: 2
Joined: Fri Nov 25, 2005 4:19 am

Need urgent reply for move_uploaded_file function

Post by sivakumari »

hi
I am working with php 4 on uploading files.
move_uploaded_file() and is_uploaded_file() is not working in php 4.can any one help me to overcome this problem.how can i upload files using php4.



I have tried to replace the function is_uploaded_file by the following function yet its not working.
I have downloaded this code from http://www.php.net/docs.php.


<?php
/* Userland test for uploaded file. */
function is_uploaded_file($filename) {
if (!$tmp_file = get_cfg_var('upload_tmp_dir')) {
$tmp_file = dirname(tempnam('', ''));
}
$tmp_file .= '/' . basename($filename);
/* User might have trailing slash in php.ini... */
return (ereg_replace('/+', '/', $tmp_file) == $filename);
}

/* This is how to use it, since you also don't have
* move_uploaded_file() in these older versions: */
if (is_uploaded_file($HTTP_POST_FILES['userfile'])) {
copy($HTTP_POST_FILES['userfile'], "/place/to/put/uploaded/file");
} else {
echo "Possible file upload attack: filename '$HTTP_POST_FILES[userfile]'.";
}
?>
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post by shiznatix »

i don't think you are using the functions correctly. try this link
http://ee.php.net/features.file-upload
which is a very good walkthorugh on how to upload files via php. make sure you read the important notices about the html form as people often forget those.
Post Reply