Jalz Posted April 26, 2010 Share Posted April 26, 2010 Hello all, I have a weird problem. I have the following code which processes the uploaded file into the relevant location. <?php $blacklist = array(".txt",".php", ".phtml"); foreach ($blacklist as $item) { if(preg_match("/$item\$/i", $_FILES['userfile']['name'])) { echo "We do not allow uploading PHP files\n"; exit; } } $uploaddir = 'Images/'; $uploadfile = $uploaddir . basename($_FILES['userfile']['name']); if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) { echo "File is valid, and was successfully uploaded.\n"; } else { echo "File uploading failed.\n"; } ?> I know the script is far from secure, but Im working through an example which will eventually add hashing to filename and do a more thorough check on the filetypes allowed etc. My question is, this script at present obtains the file I have selected and places it in the images folder. However when I navigate to that folder and double click on the file I've uploaded, the dialog prompt opens up and says "program name" can't open this picture because you dont have permission to access the file location - or a pdf would say error opening document - Access denied. When I manually copy a file or image to the same location using the Windows environment, it seems to work fine? Anyone shed some light on this please? Thanks Jalz Quote Link to comment https://forums.phpfreaks.com/topic/199824-uploading-and-moving-files-viewing-problem/ Share on other sites More sharing options...
Jalz Posted April 26, 2010 Author Share Posted April 26, 2010 OK, Just realised if I open my browser and point to the relevant location to the uploaded file, the image does display OK in the browser. If that is the case I think I may be worrying about something I dont need to worry about. Ill see if the database can acces sthe files uploaded and if they can then I'm back in business. Thanks Jalz Quote Link to comment https://forums.phpfreaks.com/topic/199824-uploading-and-moving-files-viewing-problem/#findComment-1048931 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.