djcrisp22 Posted October 4, 2008 Share Posted October 4, 2008 when i run this script on my server. when i click upload button. all i get is blank white space??? what am i doing wrong???? any help is appreciated. also, is there a way to save the uploaded file to folder??? here is my code <form action="do_upload.php" enctype="multipart/form-data" method="PoST"> <input type="hidden" name="MAX_FILE_SIZE" value="992000" /> <p> <strong>File to upload:</strong> <input type="file" name="fileupload" /></p> <p><input type="submit" value="upload!" /></p> </form> <?php $file_dir = "upload/"; for each($_FILES as $file_name => $file_array) { echo "path: ".$file_array['"tmp_'name"]."<br />\n"; echo "name: ".$file_array[''"name"]."<br />\n"; echo "type: ".$file_array["'type'"]."<br />\n"; echo "size: ".$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 ("couldn't copy"); echo "file was moved!<br />"; } } ?> thanks in advance :-) Link to comment https://forums.phpfreaks.com/topic/127053-php-file-upload-problem/ Share on other sites More sharing options...
R0bb0b Posted October 4, 2008 Share Posted October 4, 2008 you really need to work on your single and double quotes here: <?php $file_dir = "upload/"; for each($_FILES as $file_name => $file_array) { echo "path: ".$file_array['"tmp_'name"]."<br />\n"; echo "name: ".$file_array[''"name"]."<br />\n"; echo "type: ".$file_array["'type'"]."<br />\n"; echo "size: ".$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 ("couldn't copy"); echo "file was moved!<br />"; } } ?> You can read up on strings and how single and double quotes interact with eachother here http://us3.php.net/types.string. Link to comment https://forums.phpfreaks.com/topic/127053-php-file-upload-problem/#findComment-657230 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.