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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.