paulman888888 Posted October 22, 2008 Share Posted October 22, 2008 I upload a file from my application but dont give it a variable name. How do i get PHP to find the file without me telling it the variable name? Thankyou Paul Link to comment https://forums.phpfreaks.com/topic/129601-quick-question/ Share on other sites More sharing options...
ToonMariner Posted October 22, 2008 Share Posted October 22, 2008 what do you mean you don't give it a variable name???? any files uploaded will be available in the $_FILES super global - to grab the file you want you'll need $_FILES['tmp_name']. Link to comment https://forums.phpfreaks.com/topic/129601-quick-question/#findComment-671867 Share on other sites More sharing options...
feidakila Posted October 22, 2008 Share Posted October 22, 2008 In the form: <input type="file" name="image"/> In the script target script: $destiny_path is where you want the file to be copied, for example: http://www.yoursite/images/my_image.jpg if ($_FILES['image']['type']=='image/jpeg' || $_FILES['image']['type']=='image/png' || $_FILES['image']['type']=='image/gif') if (!is_file($destiny_path)) { copy($_FILES['image']['tmp_name'], $destiny_path); else {echo"error: the file exists";} } Link to comment https://forums.phpfreaks.com/topic/129601-quick-question/#findComment-671881 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.