richardjh Posted December 3, 2008 Share Posted December 3, 2008 Hello I'm testing a small script which stopped working when I moved hosting. It is a file upload script. I created a html form with some variables which I pass to a php handling page. This handling page is simply echoing the _POST variables so I know they are getting to the handling page. this is the short form: echo "<form action=\"modules.php\" method=\"post\" ENCTYPE=\"multipart/form-data\">\n"; echo "<INPUT TYPE=\"hidden\" name=\"op\" value=\"modload\">\n"; echo "<INPUT TYPE=\"hidden\" name=\"name\" value=\"$modname\">\n"; echo "<INPUT TYPE=\"hidden\" name=\"file\" value=\"test\">\n"; echo '<input type="hidden" name="member_name" value="'.$check.'" />'; echo '<input type="hidden" name="MAX_FILE_SIZE" value="9000000" />'; echo "<center><table border=\"0\" cellpadding=\"2\">\n"; echo "<tr><td align=\"center\"><font class=\"title\"><b>"._MEMUP."</b></font></td></tr>\n"; echo "<tr><td>please choose an <b>mp3 or wav</b> file to upload:<p> <input name='uploadedfile' type='file' /><br />"; echo "</td></tr>\n"; echo "<tr><td><input type=\"submit\" value=\"Upload File\" /> <input type=\"reset\" value=\"Clear\"></td></tr>\n"; echo "</table></center>\n"; echo "</form>\n"; this form is sent to this php page which simply echos the variables: $op = $_POST['op']; $modload = $_POST['name']; $file = $_POST['file']; $member_name = $_POST['member_name']; $uploadedfile = $_POST['uploadedfile']; echo '<br>'; echo '1 -'; echo $uploadedfile; echo '<br>'; echo '2 -'; echo $member_name; echo '<br>'; echo '1 -'; echo $op; echo '<br>'; echo '3 -'; echo $file; echo '<br>'; echo '4 -'; echo $modload; and the output is something like this: 1 - 2 -billy 1 -modload 3 -test 4 -Members_Photo_Upload My question: Why can't I get an echo output for number 1 ( echo $uploadedfile; ) ? thanks for your help R Quote Link to comment https://forums.phpfreaks.com/topic/135314-post-variable-echo-problem/ Share on other sites More sharing options...
Mark Baker Posted December 3, 2008 Share Posted December 3, 2008 $uploadedfile isn't a simple string parameter, but is actually details about the file that has been uploaded. It's actually an array of data identifying the location of the file, name, etc. Try using print_r($uploadedfile) rather than echo($uploadedfile) to see what that gives you. Quote Link to comment https://forums.phpfreaks.com/topic/135314-post-variable-echo-problem/#findComment-704878 Share on other sites More sharing options...
PFMaBiSmAd Posted December 3, 2008 Share Posted December 3, 2008 $_POST['uploadedfile'] does not exist. The result of the upload would be in $_FILES['uploadedfile'] Ref: http://us.php.net/features.file-upload Quote Link to comment https://forums.phpfreaks.com/topic/135314-post-variable-echo-problem/#findComment-704947 Share on other sites More sharing options...
ionik Posted December 3, 2008 Share Posted December 3, 2008 var_dump($_FILES['uploadedfile']); Quote Link to comment https://forums.phpfreaks.com/topic/135314-post-variable-echo-problem/#findComment-704960 Share on other sites More sharing options...
Mark Baker Posted December 3, 2008 Share Posted December 3, 2008 $_POST['uploadedfile'] does not exist. The result of the upload would be in $_FILES['uploadedfile']Ach! Yes. Not got my thinking head on today Quote Link to comment https://forums.phpfreaks.com/topic/135314-post-variable-echo-problem/#findComment-704982 Share on other sites More sharing options...
richardjh Posted December 4, 2008 Author Share Posted December 4, 2008 Thanks guys, I can see where I've gone wrong now I've read up a bit on it - although the subject remains a little tricky to figure out (for me anyway). Quote Link to comment https://forums.phpfreaks.com/topic/135314-post-variable-echo-problem/#findComment-705779 Share on other sites More sharing options...
richardjh Posted December 4, 2008 Author Share Posted December 4, 2008 I tried to modify my post above to add this but I took too long and it won't let me now. So... I have a similar problem here and again it has stumped me. $options = "<a href=\"page.php?name=News&file=audiodel&op=AudioDelete&ext=$ext&sid=$sid\">Delete</a>"; } else { $options = ""; } if (file_exists("sound/$sid.mp3")) { $ext = $_FILES["uploadedfile"]["type"]; $file1 = "<a target=\"_blank\" href=\"http://ukauthors.com/sound/$sid.mp3\"><img style=\"border: 0px solid ; width: 20px; height: 20px;\" alt=\"mp3 file format\" src=\"images/playdot.jpg\" align=\"middle\"></a> <b><font color=\"yellow\">Listen to this on</font><a target=\"_blank\" href=\"sound/$sid.mp3\"> UKAudio</a> (mp3) [ - $options - ]</b>"; } In the above code I'm trying to create the variable $ext filled with the file type of the found file so that it can be included in the URL. However every which way i try, I cannot get any value for $ext. Even if I just put $ext = 'mp3'; I still cannot get an output in the URL the output: http//: thedomainname.com/page.php?name=News&file=audiodel&op=AudioDelete&ext=&sid=22339 any ideas what I'm obviously doing wrong? thanks Quote Link to comment https://forums.phpfreaks.com/topic/135314-post-variable-echo-problem/#findComment-705784 Share on other sites More sharing options...
premiso Posted December 4, 2008 Share Posted December 4, 2008 My 2 cents, the file ("sound/$sid.mp3") does not exist so it is not entering into that if statement. Does $file1 echo out anything? The statement that you can manually set it to "mp3" and not get a value is what made me come to that conclusion. Quote Link to comment https://forums.phpfreaks.com/topic/135314-post-variable-echo-problem/#findComment-705943 Share on other sites More sharing options...
richardjh Posted December 4, 2008 Author Share Posted December 4, 2008 Yep, the file does exist and the URL is echoed fine. the script works fine and executes correctly apart from the $ext variable not receiving the value i set, either using the $ext = $_FILES["uploadedfile"]["type"]; or $ext = 'mp3'; I just need to output the file type of the sound file that is found (either mp3, wav or wma) and assign this to the variable $ext. Anyone? Quote Link to comment https://forums.phpfreaks.com/topic/135314-post-variable-echo-problem/#findComment-706082 Share on other sites More sharing options...
premiso Posted December 4, 2008 Share Posted December 4, 2008 Yep, the file does exist and the URL is echoed fine. the script works fine and executes correctly apart from the $ext variable not receiving the value i set, either using the $ext = $_FILES["uploadedfile"]["type"]; or $ext = 'mp3'; I just need to output the file type of the sound file that is found (either mp3, wav or wma) and assign this to the variable $ext. Anyone? Than you are overriding $ext somewhere else. I would search your code for $ext and see where it is being set and where it might possibly be overwritten. I bet if you put a echo $ext; right after the declaration it will echo out the correct value. Quote Link to comment https://forums.phpfreaks.com/topic/135314-post-variable-echo-problem/#findComment-706097 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.