开发者

PHP storing file name from HTML for and saving to variable

I am uploading a file to a server through an HTML form and then emailing the HTML form content to myself. I can store all the form values into PHP variables like this...

$name = strip_tags($_POST["name"]); 
$email = strip_tags($_POST["email"]);
$phone = strip_tags($_POST["phone"]);

but can not store the file name of the uploaded file in the same way. ex..

$uploadFile0 = strip_tags($_POST["uploadFile0"]);

I'm storing the file(s) to my server using a loop.

$i = 0;
    while(isset($_FILES['uploadFile'. $i])){
       echo 'item' . $i . 'present';
        $file_name = $_FILES['uploadFile'. $i]['name'];
        $file_name = stripslashes($file_name);
        $file_name = str_replace("'","",$file_name);
        $copy = copy($_FILES['uploadFile'. $i]['tmp_name'], $folderPath . $file_name);
        if($copy){
            echo "$file_name | uploaded sucessfully!<br&开发者_开发百科gt;";
        }else{
            echo "$file_name | could not be uploaded!<br>";
        }
        $i++;
    };

Basically I want to capture the name of the file to a variable and echo it out in an email. I have a feeling I'm staring at the answer but I just can't put it together. Thanks in advance for the help!


Will $_FILES['uploadFile'. $i]['name'] not give you the name of the file?

Or just to grab the first one $_FILES['uploadFile0']['name']

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜