aschulz90 Posted July 31, 2008 Share Posted July 31, 2008 Hi I have this function and it returns all the values correctly but I can't find it on the server or local machine ever, its annoying because it will return the size and location I want it to be, but its not there (the temporary file never seems to be there either). Where is the file actually being saved to? or where should it, why won't it save there? here's the code function Uploader() { if (($_FILES["file"]["type"] == "application/msword") && ($_FILES["file"]["size"] < 100000)) { if ($_FILES["file"]["error"] > 0) { echo "Return Code: " . $_FILES["file"]["error"] . "<br />"; } else { echo "Upload: " . $_FILES["file"]["name"] . "<br />"; echo "Type: " . $_FILES["file"]["type"] . "<br />"; echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />"; echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />"; if (file_exists("/upload/" . $_FILES["file"]["name"])) { echo $_FILES["file"]["name"] . " already exists. "; } else { move_uploaded_file($_FILES["file"]["tmp_name"], "/upload/" . $_FILES["file"]["name"]); echo "Stored in: " . "/" . $_FILES["file"]["name"]; } } } else { echo "Invalid file"; } } Thanks for any help. Link to comment https://forums.phpfreaks.com/topic/117615-solved-upload-function-not-working/ Share on other sites More sharing options...
ainoy31 Posted July 31, 2008 Share Posted July 31, 2008 you are not telling it where to load the file. no target path. check out http://www.tizag.com/phpT/fileupload.php Link to comment https://forums.phpfreaks.com/topic/117615-solved-upload-function-not-working/#findComment-605006 Share on other sites More sharing options...
akitchin Posted July 31, 2008 Share Posted July 31, 2008 you are telling it where to load the file, ignore ainoy. one thing to check is what move_uploaded_file() is returning. it will only jog an error if it wasn't moved for some unknown reason. try this: move_uploaded_file() or die('file could not be moved for some reason'); this will force a fail in the case that move_uploaded_file() returns FALSE, indicating a botched copy job. an additional check that might help is using file_exists() AFTER trying to copy the file over. Link to comment https://forums.phpfreaks.com/topic/117615-solved-upload-function-not-working/#findComment-605019 Share on other sites More sharing options...
ainoy31 Posted July 31, 2008 Share Posted July 31, 2008 sorry man. i was reading it fast. Link to comment https://forums.phpfreaks.com/topic/117615-solved-upload-function-not-working/#findComment-605022 Share on other sites More sharing options...
aschulz90 Posted August 1, 2008 Author Share Posted August 1, 2008 Thanks akitchin (don't worry about it ainoy), it died, any ideas why it would (hate to be Mr. Needy but I have no idea why...) Link to comment https://forums.phpfreaks.com/topic/117615-solved-upload-function-not-working/#findComment-605443 Share on other sites More sharing options...
PFMaBiSmAd Posted August 1, 2008 Share Posted August 1, 2008 Add the following two lines after your first opening <?php tag to get php to tell you why the function is failing - ini_set ("display_errors", "1"); error_reporting(E_ALL); My guess is that the move_uploaded_file() will generate an error about the /upload/ path not existing. The leading slash refers to the root of the current drive. Link to comment https://forums.phpfreaks.com/topic/117615-solved-upload-function-not-working/#findComment-605445 Share on other sites More sharing options...
aschulz90 Posted August 1, 2008 Author Share Posted August 1, 2008 Wow that makes me feel like a dumbass! (but really happy I can debug my code!) now here are the error I am getting: Warning: move_uploaded_file(Tryit.doc) [function.move-uploaded-file]: failed to open stream: Permission denied in C:\Web Data\Inetpub\wwwroot\GOVERNMENT\Test.php on line 28 Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'C:\WINDOWS\TEMP\phpAB.tmp' to 'Tryit.doc' in C:\Web Data\Inetpub\wwwroot\GOVERNMENT\Test.php on line 28 file could not be moved for some reason Link to comment https://forums.phpfreaks.com/topic/117615-solved-upload-function-not-working/#findComment-605454 Share on other sites More sharing options...
aschulz90 Posted August 1, 2008 Author Share Posted August 1, 2008 I meant errors sorry about that. I can't seem to manage to change the default location of the temp file, I want to move the file to a folder on the web data folder. I just tried changing the windows permissions and that didn't seem to help either. Link to comment https://forums.phpfreaks.com/topic/117615-solved-upload-function-not-working/#findComment-605456 Share on other sites More sharing options...
aschulz90 Posted August 1, 2008 Author Share Posted August 1, 2008 Sorry for Triple posts...But its working! I needed to allow the internet user account to access that page, now its time to make some user accounts for the employee's here, thanks for all your help! Link to comment https://forums.phpfreaks.com/topic/117615-solved-upload-function-not-working/#findComment-605482 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.