In linux, how does one upload files to the server using PHP?

Source: Internet
Author: User
In linux, how does one upload files to the server using PHP? The server software is apache2php. in ini, upload_tmp_dir & quot; optlamppapache2htdocsupload & quot; the upload read/write permission page displays the result: Storedin: tmpphppkZB34tmp with the same read/write permission... in linux, how does one upload files to the server using PHP?
The server software is apache2.
Php. ini
Upload_tmp_dir = "/opt/lampp/apache2/htdocs/upload /"

Upload has read and write permissions
The page displays the following results:
Stored in:/tmp/phppkZB34
Tmp also has read and write permissions

But the file "phppkZB34" cannot be found in tmp.

Reply content:

In linux, how does one upload files to the server using PHP?
The server software is apache2.
Php. ini
Upload_tmp_dir = "/opt/lampp/apache2/htdocs/upload /"

Upload has read and write permissions
The page displays the following results:
Stored in:/tmp/phppkZB34
Tmp also has read and write permissions

But the file "phppkZB34" cannot be found in tmp.

After uploading a file, you need to move the/tmp/phppkZB34 file (using the move_uploaded_file function) to your own directory. After the session ends,/tmp/phppkZB34 will be deleted. Ask du Niang about how to use the function.

php
  Return
"; }else if ((($_FILES["file"]["type"] == "image/gif") || ($_FILES["file"]["type"] == "image/jpeg") || ($_FILES["file"]["type"] == "image/pjpeg") || ($_FILES["file"]["type"] == "image/png")) && ($_FILES["file"]["size"] < (500*1024))) { if ($_FILES["file"]["error"] > 0) { echo "Return Code: " . $_FILES["file"]["error"] . "
"; } else { echo "Image Details:
    "; echo "
  • Upload: " . $_FILES["file"]["name"] . "
  • "; echo "
  • Type: " . $_FILES["file"]["type"] . "
  • "; echo "
  • Size: " . ($_FILES["file"]["size"] / 1024) . " Kb.
  • "; //echo "Temp file: " . $_FILES["file"]["tmp_name"] . "
    "; if (file_exists("upload/" .date('Ymd_'). $_FILES["file"]["name"])){ echo "
    ".date('Ymd_').$_FILES["file"]["name"]." already exists.
    Fail to Upload.
    "; echo " Click HERE to check."; }else{ move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" .date('Ymd_'). $_FILES["file"]["name"]); echo "
  • Stored in: " . "upload/" .date('Ymd_'). $_FILES["file"]["name"].".
  • "; echo "
  • Permanent Link: ". "upload/" .date('Ymd_'). $_FILES["file"]["name"]."
  • "; echo "
"; } } } else { echo "
Invalid file.
Only png/jpeg/jpg/gif files under 500Kb can be uploaded here.
"; }?>

I wrote it for your reference.

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.