Manzar Hussain
Manzar Hussain

Reputation: 11

PHP error.. the same code used to work a month before and now its showing an error.. copy(): Filename cannot be empty [file]

I jus have started getting error Array ( [type] => 2 [message] => copy(): Filename cannot be empty [file] => /home/fraptech/public_html/notredamedelhi.com/modifyhome.php [line] => 73 ) i.e. the HTTP_POST_FILES line Before a month the files wer getting uploaded successfully. This problem has started only now. And i haven't modified the code since then.

<?php
if ($_POST['Upload']) 
{
$file_name = $HTTP_POST_FILES['ufile']['name'];
$new_file_name="slider_photo1.jpg";
$path= "images/".$new_file_name;
if($ufile !=none)
{
if(copy($HTTP_POST_FILES['ufile']['tmp_name'], $path))
{
echo "Successful<BR/>"; 
}
 else
{
echo "Error ";
print_r(error_get_last());
}

Please help with the code.

Upvotes: 0

Views: 80

Answers (1)

developerCK
developerCK

Reputation: 4506

I can guess, php version has updated on server.

b/c $HTTP_POST_FILES is deprecated.(PHP 4 >= 4.1.0, PHP 5)

http://php.net/manual/en/reserved.variables.files.php.

so this is not there.

4.1.0 Introduced $_FILES that deprecated $HTTP_POST_FILES.

Upvotes: 1

Related Questions