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.