About uploadify upload plugin get file name problem

Source: Internet
Author: User
Tags rtrim
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);
}

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.