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 Quote Link to comment 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']. Quote Link to comment 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";} } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.