PHP can't upload file from HTML form

后端 未结 2 1246
抹茶落季
抹茶落季 2021-01-22 13:33

This is how I handle my form:

        # Create the message
        # ----------------------------------------------------------------
        $name = $_POST[\'na         


        
相关标签:
2条回答
  • 2021-01-22 14:23

    Two things:
    1. Is the form set to:

    <form method="POST" enctype="multipart/form-data" action="INSERT ACTION">
    

    2. Is the folder your posting the file to, is it set to 777?

    0 讨论(0)
  • 2021-01-22 14:34

    Your form needs to have the appropriate enctype attribute set, ie

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

    Update

    A couple of suggestions...

    1. Check the file type and do any other general validation before you move the uploaded file. That should be your last step.
    2. Can't remember exactly right now but I don't think you'll get anything useful (or at all) in the $_POST['file'] value. Use the $_FILES array for all uploaded file data.
    0 讨论(0)
提交回复
热议问题