Note that there are some explanatory texts on larger screens.

plurals
  1. POUploading of Image file to database
    primarykey
    data
    text
    <p>I have the html code like : - </p> <pre><code>&lt;form id="form" name="form" action="banner_ad_post.php" method="post" enctype="multipart/form-data"&gt; &lt;p&gt; &lt;label for="banner_name"&gt;&lt;font color="#FF0000"&gt; * &lt;/font&gt;Banner Name: &lt;/label&gt; &lt;input type="text" name="banner_name" id="banner_name" value="" maxlength="100" required="required"/&gt; &lt;/p&gt; &lt;p&gt; &lt;label for="Banner_website_url"&gt;&lt;font color="#FF0000"&gt; * &lt;/font&gt;Banner website Url: &lt;/label&gt; &lt;input type="url" name="banner_site_url" id="banner_site_url" value="" maxlength="100" required="required"/&gt; &lt;/p&gt; &lt;p&gt; &lt;label for="banner_image_url"&gt;Banner Image Url: &lt;/label&gt; &lt;input type="file" name="file" id="file" value="" accept="image" placeholder="Browse from hard disk" onchange="img_path()"/&gt; &amp;nbsp; &lt;font color="#FF0000"&gt; OR&lt;/font&gt; &amp;nbsp; &lt;input type="url" name="banner_image_url" id="banner_image_url" value="" maxlength="100" placeholder="Enter the url from website." onchange="validate()"/&gt; &amp;nbsp; &lt;/p&gt; &lt;p&gt; &lt;label for="submit"&gt; &lt;/label&gt; &lt;input type="submit" id="submit" name="submit" value="Submit" onclick="preview()" /&gt; &lt;/p&gt; &lt;/form&gt; </code></pre> <p>and the php script like : -</p> <pre><code>&lt;?php if(isset($_POST['banner_name']) &amp;&amp; isset($_POST['banner_site_url']) &amp;&amp; isset($_POST['banner_image_url']) &amp;&amp; isset($_FILES['file']['name'])) { $banner_name=$_POST['banner_name']; $banner_name=strip_tags($banner_name); $banner_site_url=$_POST['banner_site_url']; $banner_site_url=strip_tags($banner_site_url); $banner_image_url=$_POST['banner_image_url']; $banner_image_url=strip_tags($banner_image_url); $name=$_FILES['file']['name']; $size=$_FILES['file']['size']; $type=$_FILES['file']['type']; $tmp_name=$_FILES['file']['tmp_name']; $error=$_FILES['file']['error']; $maxsize = 512000; $location='uploads/'; if(!empty($banner_image_url)) { $file_location=$banner_image_url; ?&gt; &lt;div id="img"&gt; &lt;img src="&lt;?php echo $file_location?&gt;" align="left" width="200px" height="200px"&gt; &lt;/div&gt; &lt;?php } elseif (!empty($name)) { $file_location=$location.$name; ?&gt; &lt;div id="img"&gt; &lt;img src="http://localhost/leadstool/&lt;?php echo $file_location?&gt;" align="left" width="200px" height="200px"&gt; &lt;/div&gt; &lt;?php } if(!empty($banner_name) &amp;&amp; !empty($banner_site_url)) { $query="INSERT INTO `banner_ad` VALUES('','$id','$banner_name','$file_location','$banner_site_url','0',now())"; if($query_run=mysql_query($query)) { if($size &lt;= $maxsize) { if(move_uploaded_file($tmp_name,$location.$name)) { echo'&lt;font color="green"&gt;File uploaded &amp; has been sent for approval.&lt;/font&gt;'; } else { echo'&lt;font color="red"&gt;File can not be uploaded.&lt;/font&gt;'; } } else { echo'&lt;font color="green"&gt;Your information has been uploaded and has been sent for approval.&lt;/font&gt;'; } } else { echo'&lt;font color="red"&gt; The request can not be performed.&lt;/font&gt;'; } } else { echo'&lt;font color="red"&gt;These fields are mandatory.&lt;/font&gt;'; } } ?&gt; </code></pre> <p>Here, the problem is due to some reason move_uploaded_file() method is unable to upload the file in the database. But it still gives the output like " File uploaded &amp; has been sent for approval ". Now, I don't understand what exactly am i missing here? </p> <p>Any help will be appreciated ... Thank you in advance! </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload