简体   繁体   中英

How do I check if a file is selected for <input type=“file”> in PHP?

I want to check if the user has selected an image for upload. What is the php script to do that after the user has clicked submit...

I tried file_exist(), but that expects a string rather than an array and it seems that only works for an absolute path. Since I don't know which folder the user is going to upload from, this doesn't work.

Can someone help?

Take a look at the $_FILES superglobal .

Tizag Tutorial: http://www.tizag.com/phpT/fileupload.php

If you do a print_r($_FILES) , you will see everything you need.

You need to use the super global variable $_FILES .

More info .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM