The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Input type file not working, why?
Gerry Roston
post May 4 2022, 09:53 PM
Post #1





Group: Members
Posts: 3
Joined: 4-May 22
Member No.: 28,338



I am beyond confused. Here is a some of my html code (which I copied using my browser’s ‘show source’ capability). Very simple.
CODE
<div style="width: 40%; float: right;">
  <label style="position: absolute; top: 250px;">File with new logo:</label>
  <input style="position: absolute; top: 280px;" type="file" name="LogoFile">
</div>

In my code, I have some PHP to gather the data that is inputted and store it in a database. The code works just fine. However, I added two lines to the code:
CODE
echo "checking filename:  ";
echo $_FILES['LogoFile']['name'];

and the filename comes back empty, despite my having selected a file. Even weirder, the code used to work, but only stopped working once I moved the code into the <div> and added the style stuff. I suspect that I am missing something trivially easy – can you please point me to a solution.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post May 5 2022, 08:55 AM
Post #2


.
********

Group: WDG Moderators
Posts: 9,630
Joined: 10-August 06
Member No.: 7



QUOTE(Gerry Roston @ May 5 2022, 04:53 AM) *

I added two lines to the code:
CODE
echo "checking filename:  ";
echo $_FILES['LogoFile']['name'];

and the filename comes back empty, despite my having selected a file.

Looks correct to me. Could it be that the above lines are in the wrong place in the PHP script?

QUOTE
Even weirder, the code used to work, but only stopped working once I moved the code into the <div> and added the style stuff.

I see no reason for that.

(As a sidenote, I wouldn't use CSS absolute positioning like that, also I wouldn't use CSS as nline styles for practical reasons).
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post May 5 2022, 11:29 AM
Post #3


.
********

Group: WDG Moderators
Posts: 9,630
Joined: 10-August 06
Member No.: 7



Seems the thread got closed by mistake. Opened now. blush.gif
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post May 5 2022, 11:58 AM
Post #4


🌟Computer says no🌟
********

Group: WDG Moderators
Posts: 20,716
Joined: 9-August 06
Member No.: 6



When you moved the code, did you include the PHP tags?
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Gerry Roston
post May 5 2022, 05:51 PM
Post #5





Group: Members
Posts: 3
Joined: 4-May 22
Member No.: 28,338



I found my stupid mistake! I had put the new <div> code outside of the <form> tag. Once I adjusted that, everything worked fine.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
2 User(s) are reading this topic (2 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 28th March 2024 - 06:12 AM