SoFunction
Updated on 2025-04-08

PHP realizes simple upload of pictures

//Upload the file. Linux+apache+php3/4 test passed. IIS test failed, win+apache+php not tested
<?php  
if ($HTTP_POST_VARS["upload"]=="Upload"){
file://here you can add functions such as checking file name, format, image size, etc.
file://$picurl full path to local system
file://$picurl_name The temporary file name after uploading
file://$picurl_size file size (bytes)
file://$picurl_type file MIME type

copy("$picurl","/where/you/want/put/the/uploaded/files/in/$picurl_name");  
exit;  
}  
?>  
<form action="." method="post" enctype="multipart/form-data" name="UL">  
<!--Note: 'enctype="multipart/form-data"' must be added here, otherwise it will not be generated.
Passing action-->
<input type="file" name="picurl" size="15"  
accept="image/x-png,image/gif,image/jpeg">  
<input type="submit" name="upload" value="upload">
</form>