By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,695 Members | 1,651 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,695 IT Pros & Developers. It's quick & easy.

how upload files

P: n/a
how can i submit files in php. i have created one file index.html which
contains following code

<html>
<head>
<title>
File Upload Demo
</title>
</head>
<body>
<form method="post" action="upload.php" type="multipart/form-data">
<input type="hidden" name="MAX_FILE_SIZE" value="300000">
<input type="file" name="userfile">
<br><br><br>
<input type="submit" name=submit value="Upload">
</form>
</body>
</html>
i have created file upload.php and written folllowing code in this file

echo "file name on client machine : " . $_FILES["userfile"]["name"] .
"<br>";
echo "file type is : " . $_FILES["userfile"]["type"] . "<br>";
echo "file size is : " . $_FILES["userfile"]["size"] . "<br>";
echo "file name on server is : " . $_FILES["userfile"]["tmp_name"] .
"<br>";
echo "error in uploading file is : " . $_FILES["userfile"]["error"] .
"<br>";
but i get blank output wherever i try to print the value of super
global array $_FILES.

thxs for help in advance. pls suggest me where i am wrong

Jul 17 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
You might want to check if things are posted by include the following
at the beginning of upload.php

phpinfo( INFO_VARIABLES );

This will print a table with all the variable known to PHP. From here
you can see if $_FILES is empty. In your case it is!

You used type iso enctype in the form tag. Type is not a defined attribute
in the FORM-tag.

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

"vishal" <vi************@yahoo.co.in> wrote in message
news:11*********************@z14g2000cwz.googlegro ups.com...
how can i submit files in php. i have created one file index.html which
contains following code

<html>
<head>
<title>
File Upload Demo
</title>
</head>
<body>
<form method="post" action="upload.php" type="multipart/form-data">
<input type="hidden" name="MAX_FILE_SIZE" value="300000">
<input type="file" name="userfile">
<br><br><br>
<input type="submit" name=submit value="Upload">
</form>
</body>
</html>
i have created file upload.php and written folllowing code in this file

echo "file name on client machine : " . $_FILES["userfile"]["name"] .
"<br>";
echo "file type is : " . $_FILES["userfile"]["type"] . "<br>";
echo "file size is : " . $_FILES["userfile"]["size"] . "<br>";
echo "file name on server is : " . $_FILES["userfile"]["tmp_name"] .
"<br>";
echo "error in uploading file is : " . $_FILES["userfile"]["error"] .
"<br>";
but i get blank output wherever i try to print the value of super
global array $_FILES.

thxs for help in advance. pls suggest me where i am wrong

Jul 17 '05 #2

P: n/a
After you submit the form try to print_r($_FILES), that wil help you!

http://www.DevPlug.com --Connecting Developers
Posted from: http://www.devplug.com/ftopic{TOPIC_ID}.htm
Jul 17 '05 #3

P: n/a
message unavalaible

http://www.DevPlug.com --Connecting Developers
Posted from: http://www.devplug.com/ftopic22244.htm
Jul 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.