PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, February 3, 2022

[FIXED] I am not able to retrieve file name after submission

 February 03, 2022     file, mamp, php     No comments   

Issue

if($_SERVER['REQUEST_METHOD'] == 'POST') {
        $image = $_FILES["image"]["name"];

        echo "File: " . $image;
    }

the echo is "File :" all the time

        <form action="" method="post" id="formAddProperty">
            <div id="propertyImage">
                <label for="image">Upload image:</label>
                <input type="file" name="image">
            </div>

            <input type="submit" value="Add Property" id="propertySubmit">
        </form>

I'm running a local server via mamp, is than an issue? The purpose is to get file name than its extension (which is not shown in this example).


Solution

You are missing

enctype="multipart/form-data"

in the form

<form action="" method="post" id="formAddProperty" enctype="multipart/form-data">


Answered By - Abhik Chakraborty
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing