upload image $_FILES is not set

前端 未结 7 829
星月不相逢
星月不相逢 2020-12-12 07:26

I\'m trying to upload a file to my server But the problem is the if(isset($_FILES[\'upl\'])) always returns false

my php:

if($_SERVER[\'REQUEST_METHO         


        
相关标签:
7条回答
  • 2020-12-12 07:53

    You are missing

    enctype="multipart/form-data"
    

    in the form

    <form action="" method="post" enctype="multipart/form-data">
    
    0 讨论(0)
  • 2020-12-12 07:56

    Very important attribute when uploading files is the enctype:

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

    0 讨论(0)
  • 2020-12-12 07:56

    You missed enctype parameter in your from attributes. Its not necessary if you used GET method for file uploading. But if you used POST method for file uploading then, your form parameter should be like this,

    <form method="post" action="upload.php" enctype="multipart/form-data">
    
    0 讨论(0)
  • 2020-12-12 08:07

    For file upload, you need to add attribute:

    enctype="multipart/form-data"
    

    So, your updated code should be:

    <form action="" method="post" enctype="multipart/form-data">
    
    0 讨论(0)
  • 2020-12-12 08:11

    you should add the attribute enctype="multipart/form-data" in form tag to upload the file into server....

    0 讨论(0)
  • 2020-12-12 08:17

    You need to change

    <form action="" method="post">

    to

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

    0 讨论(0)
提交回复
热议问题