homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

$ FILES['uploadedfile']['tmp name'] is empty
$_FILES['uploadedfile']['tmp_name'] is empty after user uploads a file

 9:23 am on Mar 16, 2009 (gmt 0)

my form to upload files(without designing code):
<form method="post" name="form1" id="form1" action="<?php $PHP_SELF ?>">

<input name="frm_title" type="text" id="frm_title" size="50" />

<input type="file" id="uploadedfile" name="uploadedfile"/>

<textarea name="frm_desc" id="frm_desc" cols="47" rows="5"></textarea>

<input name="form_posted" type="hidden" value="true" />

<input name="btn_save" type="submit" class="bg-blue" value="Save and Continue" />

code to capture the posted data:

$query = "insert into latest_news_tb(title,description)values('$_POST[frm_title]','$_POST[frm_desc]')";
$db = new Database();
$return_id = $db->query_mysql_insert_id($query);

$target_path = "../media_centre/images_media/";
$target_path = $target_path."LN".$return_id.".jpg";

$name = $_FILES['uploadedfile']['tmp_name'];
print $name;

//if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
//print 'file uploaded';

here I'm trying to upload the file. but $_FILES['uploadedfile']['tmp_name'] is empty. why is that?

gettin the $return_id works fine.

tried the following:

1.upload a tiny image to see whether the problem was with the MAX_FILE_SIZE
2.made the folder file permissions to 777.
3. the disk also have enough space


how is this possible?

even the $_FILES['uploadedfile']['name'], $_FILES['uploadedfile']['size'] is empty.

Thanks in advance!



 10:02 am on Mar 16, 2009 (gmt 0)

Check if php.ini has file uploads enabled:

; File Uploads ;

; Whether to allow HTTP file uploads.
file_uploads = On


 10:11 am on Mar 16, 2009 (gmt 0)

thanks for the reply. the php.ini is :

; File Uploads ;

; Whether to allow HTTP file uploads.
file_uploads = On

; Temporary directory for HTTP uploaded files (will use system default if not
; specified).
;upload_tmp_dir =

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

well the other uploading parts are working well too. sigh sigh!


 11:52 am on Mar 16, 2009 (gmt 0)

Your form tag needs to include enctype="multipart/form-data":

<form method="post" name="form1" id="form1" enctype="multipart/form-data" action="<?php $PHP_SELF ?>">


 12:05 pm on Mar 16, 2009 (gmt 0)

no way! I'm surely blind :) thanks a bunch!


 4:01 pm on Mar 17, 2009 (gmt 0)

The enctype is usually it, now that you've solved that Google for "$PHP_SELF vulnerability" and change the form action. :-)


 3:23 am on Mar 18, 2009 (gmt 0)

it works just fine. my original question was solved. n thanks to Sonjay for that!
As why change $PHP_SELF? you mean to specify the page name like "sample.php" instead?
wil have a look thanks rocknbil!

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved