Jump to content

Recommended Posts

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

 

Link to comment
https://forums.phpfreaks.com/topic/135314-post-variable-echo-problem/
Share on other sites

$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.

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

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.

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?

 

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.