Jump to content

file upload error


speedy_rudolf

Recommended Posts

Hi. I have the following code:

<?php
$host="";
$username="";
$password="";
$db_name="";
$tbl_name="topic";
// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
mysql_select_db("$db_name")or die("cannot select DB");

$name=$_POST['name'];
$detail=$_POST['details'];

$sql="INSERT INTO $tbl_name(topic, detail, datetime)VALUES('$name', '$detail', NOW())";
$result=mysql_query($sql);

if($result){
echo("Topic created. ");
$sql3="SELECT max(id) FROM $tbl_name";
$result3=mysql_query($sql3);
$tbl_name2="top_img";
for($i=1; $i<11; $i++){

$uploaddir = '/imgs/';
$uploadfile = $uploaddir . basename($_FILES['img'.$i]['name']);

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

print "</pre>";

echo("<br><br><a href='site.html'>HOME</a>");
?>

And the error message:

Topic created.

 

PHP Error Message

 

Warning:  move_uploaded_file(/imgs/Sunset.jpg) [function.move-uploaded-file]: failed to open stream: No such file or directory in /home/a7129718/public_html/test/add_topic.php on line 28

 

PHP Error Message

 

Warning:  move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/php73HyFd' to '/imgs/Sunset.jpg' in /home/a7129718/public_html/test/add_topic.php on line 28

 

 

Free Web Hosting

Possible file upload attack!

 

Possible file upload attack!

 

Possible file upload attack!

 

Possible file upload attack!

 

Possible file upload attack!

 

Possible file upload attack!

 

Possible file upload attack!

 

Possible file upload attack!

 

Possible file upload attack!

 

Possible file upload attack!

Here is some more debugging info:Array

(

    [img1] => Array

        (

            [name] => Sunset.jpg

            [type] => image/jpeg

            [tmp_name] => /tmp/php73HyFd

            [error] => 0

            => 71189

        )

 

    [img2] => Array

        (

            [name] =>

            [type] =>

            [tmp_name] =>

            [error] => 4

            => 0

 

bla bla bla

Any idea what the problem might be? Thanks in advance. Bye.

Link to comment
https://forums.phpfreaks.com/topic/229013-file-upload-error/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.