0

In my case i was include enctype on myform like

<form id="product_add" name="product_add" accept-charset="utf-8" action="product_add_inter.php" method="post" enctype="multipart/form-data">

then my input type file is

<input name="imagefile" class="form-control" type="file"   />

Problem is in server side i need to upload my image to distination folder.I was tried to get file from form using

$_FILES["imagefile"]["name"]

its worked and returned name of my image. But when i get the file using temp_name it return null values.

$_FILES["imagefile"]["tmp_name"]

how can i solve this.

Jeya kumar G
  • 85
  • 1
  • 7

3 Answers3

0

You can use this code to see the upload error:

print_r($_FILES['imagefile]['error']);

The error code 6 means that there is no tmp directory. Go to your php.ini and post whats behind that variable:

upload_tmp_dir =
Robin Gillitzer
  • 1,603
  • 1
  • 6
  • 17
0

First, ensure that PHP is configured to allow file uploads. In your "php.ini" file, search for the file_uploads directive, and set it to On:

file_uploads = On

Also did you check like that

echo '<pre>'; print_r($_FILES);echo '</pre>'; 

and see the result. Are you getting file array and tmp_name? check your php.ini file for file upload settings.

php.ini setting

Change the upload_max_filesize=2M to 8M

; Maximum allowed size for uploaded files.
upload_max_filesize = 8M 

; Must be greater than or equal to upload_max_filesize
post_max_size = 8M 

Here is also solution PHP file upload error tmp_name is empty

0

I have Checked your Code and its absolutly working fine

<?php
echo $_FILES["imagefile"]["name"];
?>
<form id="product_add" name="product_add" accept-charset="utf-8" action="Check.php" method="post" enctype="multipart/form-data">
<input name="imagefile" class="form-control" type="file"   />
<input type="submit" value="SUBMIT" />
</form>

Please Check If phpinfo(given below) whether "file_uploads" is ON and upload_max_filesize

<?php
echo phpinfo();
?>
Brindha Baskaran
  • 185
  • 2
  • 16