Jump to content

arning: move_uploaded_file(): The second argument to copy() function cannot be a directory in


Recommended Posts

File wont move to directory nor even upload to database 


here is my code , everything else uploads except the image 




echo $post_title=mysqli_real_escape_string($connect,$_POST['title']);

echo $post_date=date('m-d-y');

echo $post_price=mysqli_real_escape_string($connect,$_POST['price']);

echo $post_keywords=mysqli_real_escape_string($connect,$_POST['keywords']);

echo $post_content=mysqli_real_escape_string($connect,$_POST['content']);

echo $post_image=mysqli_real_escape_string($connect,$_FILES['image']['name']);

echo $image_tmp=mysqli_real_escape_string($connect,$_FILES['image']['tmp_name']);

if($post_title=='' OR $post_price=='' OR $post_content=='' OR $post_keywords=='' OR $post_image=''){

	echo "<script> alert('None of the post fields can be left blank')</script>";

}else{    //moves uploaded image into the image file 


        $insert_query="INSERT INTO posts


  echo "<script>alert('Succefully posted'); </script>";

} else "<h1> Did not work </h1>";


if (is_uploaded_file($_FILES['image']['tmp_name'])) {

echo "uploaded";

}else echo "could not upload";


        echo "<a href='logout.php'> Log out </a> <br/>";
       echo "<a href='view_posts.php'> View Posts </a>";


<?php }  ; ?> 

here is the html 


<title> inserting new posts </title>
<link rel="stylesheet" type="text/css" href="admin_style.css">



<div id="edit_postform">

<form method="post" action="insert_post.php" enctype="multipart/form-data">

<table width="600" align="centre" border"10">

<td> <h1> Insert New Post here </h1> </td>


<td> Post title <td>
<td> <input type="text" name="title" size="30"> </td>

<td> Post Price<td>
<td> <input type="text" name="price" size="30"> </td>

<td> Post keywords<td>
<td> <input type="text" name="keywords" size="30"> </td>

<td> Post image <td>	
<td> <input type="file" name="image"> </td>

<td> Post Content <td>
<td> <textarea name="content" cols="20" rows="20" size="30"> </textarea> </td>

<td> <input type="submit" name="submit" value="Publish now"> </td>



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.

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.