Uploadify Upload plugin Get file name
Question Hair title, I hope you point out;
My current program after uploading pictures can be displayed on the page, but when I press the "submit" button how to get the file name to deposit data,
The program code is as follows
test.php file
Untitled Document
uploadify.php file
*///Define a destination $targetFolder = $_post[' folder '; Relative to the root $verifyToken = MD5 (' hx110 '. $_post[' timestamp '); if (!empty ($_files) && $_post[' token ') = = $verifyToken) {//$_files["Filedata" ["name"] = $_post[' timestamp '];//change file name $tempfile = $_files[' Filedata '] [' Tmp_ Name ']; $targetPath = $_server[' Document_root '). $targetFolder; the #rtrim () function removes the character $targetfile = RTrim ($targetPath, '/') from the right end of the string. '/'. $_post[' timestamp '. $_files[' Filedata ' [' Name '];//Validate the file Type$filetypes = array (' jpg ', ' jpeg ', ' gif ', ' PNG '); File Extensions$fileparts = pathinfo ($_files[' Filedata ' [' name ']);//pathinfo function returns the information in the form of an array of files path #in_array () The function searches the array for the given value if (In_array ($fileParts [' extension '], $fileTypes)) {//move_uploaded_file ($tempFile, $targetFile); move_ Uploaded_file ($tempFile, Iconv ("UTF-8", "gb2312", $targetFile));//Solve the Chinese file name garbled or unable to upload the problem//move_uploaded_file ($tempFile , Mb_convert_encoding ($targetFile, ' gb2312 ', ' UTF-8 ')); Solve the Chinese file name garbled or unable to upload the problem (with this efficiency than iconv () lower, but Iconv has a bug more special characters can not be a reason) echo ' 1 ';} else {echo ' invalid file type. ';}}? >
Other I have not changed, are the original ecology!!
I hope you can point out, if there is a better way to roar to provide
Reply to discussion (solution)
This has a callback function, you should look at the official example. Here's a hint.
if (In_array ($fileParts [' extension '], $fileTypes)) { //move_uploaded_file ($tempFile, $targetFile); Move_uploaded_file ($tempFile, Iconv ("UTF-8", "gb2312", $targetFile)); echo "";
JS section:
' Onuploadcomplete ': function (fileobj) {//display image after successful upload $ ("form"). Append (fileobj) }
Tottyandbaty Thank you for your answer, English I do not understand ah, according to your tips to operate a bit, or not the industry, print the file name
if (Isset ($_post[' dosub ')) {
Print_r ($_post);
}