pouncer Posted January 22, 2007 Share Posted January 22, 2007 i have this code firstly, but would lie to know what parts of it mean:[code=php:0]<html><head><title>A simple file upload form</title></head><body><form action="file_uploadTest.php" enctype="multipart/form-data" method="post"><input type="hidden" name="MAX_FILE_SIZE" value="200000" /><p><strong>File to upload:</strong> <input type="file" name="fileupload"></p><p><input type="submit" value="upload!"></p></form></body></html>[/code]<input type="hidden" name="MAX_FILE_SIZE" value="200000" />200000 what?and also what this means: enctype="multipart/form-data"the actual php code to upload the file is[code=php:0] $file_dir = "dir.."; foreach($_FILES as $file_name => $file_array) { echo "path: " . $file_array['tmp_name'] . "<br>\n"; echo "name: " . $file_array['name'] . "<br>\n"; echo "size: " . $file_array['type'] . "<br>\n"; echo "type: " . $file_array['size'] . "<br>\n"; if (is_uploaded_file($file_array['tmp_name'])) { move_uploaded_file($file_array['tmp_name'], "$file_dir/$file_array[name]") or die("Couldnt copy"); echo "file was moved<br><br>"; } }[/code]is there an easier way to do this? im not sure what all the file array stuff is for and its hard to understand :shope someone can make it clear what it means thanks Link to comment https://forums.phpfreaks.com/topic/35256-file-upload-code/ Share on other sites More sharing options...
Lyleyboy Posted January 22, 2007 Share Posted January 22, 2007 [quote]i have this code firstly, but would lie to know what parts of it mean:<html><head><title>A simple file upload form</title></head><body><form action="file_uploadTest.php" enctype="multipart/form-data" method="post"><input type="hidden" name="MAX_FILE_SIZE" value="200000" /><p><strong>File to upload:</strong> <input type="file" name="fileupload"></p><p><input type="submit" value="upload!"></p></form></body></html><input type="hidden" name="MAX_FILE_SIZE" value="200000" />200000 what?and also what this means: enctype="multipart/form-data"the actual php code to upload the file is $file_dir = "dir.."; foreach($_FILES as $file_name => $file_array) { echo "path: " . $file_array['tmp_name'] . "<br>\n"; echo "name: " . $file_array['name'] . "<br>\n"; echo "size: " . $file_array['type'] . "<br>\n"; echo "type: " . $file_array['size'] . "<br>\n"; if (is_uploaded_file($file_array['tmp_name'])) { move_uploaded_file($file_array['tmp_name'], "$file_dir/$file_array[name]") or die("Couldnt copy"); echo "file was moved<br><br>"; } }is there an easier way to do this? im not sure what all the file array stuff is for and its hard to understand :shope someone can make it clear what it means thanks[/quote]Hi,200000 Bytes i.e. 2mbHope this helps Link to comment https://forums.phpfreaks.com/topic/35256-file-upload-code/#findComment-166582 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.