Skip to content
Advertisement

Can I pass a variable into an if(isset($_FILES[‘whatever’])) logical process?

I am new to PHP and am trying to create a page which will change/update/refresh depending on which form buttons are selected. This part works. The purpose of the site is to allow multiple file uploads of two types of data: PHOTO and MUSIC, along with uploads of textarea text – with each type being stored in a different location. The problem I’ve run into is in dedicating paths for each data type (for use with the move_uploaded_file command). I can set the paths in variables, but it seems the if(isset($_FILES['whatever'])) block of code cannot see those variables. I receive no errors (as you can see, I’m testing via localhost). How should I redesign my code to accomplish the objective? I’m assuming that the problem is in the way I’m approaching the project in general.

JavaScript

Advertisement

Answer

When you submit the second form (the one with the file) you don’t re-send the ‘Button’ value. To circumvent this you could add a hidden input to your file-form above the ‘Publish Entry’-submit-input like this:

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement