emmerac Posted May 31, 2008 Share Posted May 31, 2008 Hi all, I'm a complete newb and I am getting really frustrated. I am running the PHP that ships with Leopard. I am using some basic PHP code to upload a file but it will only accept files from the same directory as the .php code, so if I try to upload a file from another computer to the server I get an file does not exist error! <?php if ((($_FILES["file"]["type"] == "image/gif") || ($_FILES["file"]["type"] == "image/jpeg") || ($_FILES["file"]["type"] == "image/pjpeg")) && ($_FILES["file"]["size"] < 20000)) { 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: " . "upload/" . $_FILES["file"]["name"]; } } } else { echo "Invalid file"; } ?> Link to comment https://forums.phpfreaks.com/topic/108160-php-only-uploads-from-same-directory/ Share on other sites More sharing options...
BlueSkyIS Posted May 31, 2008 Share Posted May 31, 2008 make sure permissions are okay on /uploads in terminal: chmod somedirectory 777, or in finder, get info, open the lock if necessary (lower right), then change all permissions to read and write. p.s. I suggest that you use MAMP on Leopard and leave Apple's PHP/Apache alone. At least if you plan to make any mods/additions to PHP or plan to add MySQL. Link to comment https://forums.phpfreaks.com/topic/108160-php-only-uploads-from-same-directory/#findComment-554457 Share on other sites More sharing options...
emmerac Posted June 1, 2008 Author Share Posted June 1, 2008 I switched over to XAMPP and I am still getting the same error from the same code: Warning: file_get_contents(money.gif) [function.file-get-contents]: failed to open stream: No such file or directory in /Applications/xampp/xamppfiles/htdocs/geezum/s3up.php on line 16 Failed to read file money.gif I have chmod to 777 the upload directory. When I test it out I am simply trying to upload a small .gif that is sitting on my desktop and I get that error. Any idea's? Link to comment https://forums.phpfreaks.com/topic/108160-php-only-uploads-from-same-directory/#findComment-554581 Share on other sites More sharing options...
emmerac Posted June 2, 2008 Author Share Posted June 2, 2008 Ok, so I got the upload to work, but then after a few successful trial runs I started getting error 6 telling me that my tmp directory is not setup in my php.ini, but when I check my php.ini I see that I have it set to a /tmp folder in the /xamppfiles directory. What the heck is going on here? Link to comment https://forums.phpfreaks.com/topic/108160-php-only-uploads-from-same-directory/#findComment-555244 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.