390bay Posted April 8, 2009 Share Posted April 8, 2009 Hi there I am kind of new to php, and my work has asked me to make a file upload button - that our client can go to a webpage, click on the browse button and then upload, and have it uploaded to our ftp site. I have the script i think that is correct... BUT - if they use an ftp program it is fine as we set up a specific folder that they can only see when they use the login name and password ( it is a general one) i am guessing that because of this user name and password - the error that we get is Upload: test pic.jpg Type: image/jpeg Size: 108.01953125 Kb Temp file: /tmp/phpBtbFHq Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to access customers/test pic.jpg in /home/jetlink47/domains/jetlink.ca/public_html/upload_file.php on line 22 Stored in: customers/test pic.jpg is there a way that i can put in a user name and password into the php script "upload_file.php" so it will uplaod. here is the file_load.php script <?php if ($_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("customers/" . $_FILES["file"]["name"])) { echo $_FILES["file"]["name"] . " already exists. "; } else { move_uploaded_file($_FILES["file"]["tmp_name"], "customers/" . $_FILES["file"]["name"]); echo "Stored in: " . "customers/" . $_FILES["file"]["name"]; } } } else { echo "Invalid file"; } ?> thanks for any help Link to comment https://forums.phpfreaks.com/topic/153228-client-file-upload-button/ Share on other sites More sharing options...
Brian W Posted April 8, 2009 Share Posted April 8, 2009 First off, please use the code tags around your php/html [ code ]Like this but without the spaces in the tags[ /code ] would be Like this but without the spaces in the tags It is much easier to read code when it is like that. Secondly, move_uploaded_file() does not use FTP... it moves a temporary file (the one uploaded) from the temp folder on the server and moves it to the specified location. In this case, you are using the relative path "customers/", if that folder does not exist, then that could be the problem. If the folder does exist, then you may have a permissions issue on the server. *Does the folder "customers/" exist as a sub-folder of where file_load.php is? *What kind of server are you using (Apache on Linux, Apache on Windows, Windows IIS, ect...)? Link to comment https://forums.phpfreaks.com/topic/153228-client-file-upload-button/#findComment-804942 Share on other sites More sharing options...
390bay Posted April 9, 2009 Author Share Posted April 9, 2009 Sorry i am very new to this wesite and to PHP. I am just a graphic designer trying to do a fav to the owner of my workplace. the folder is there, and created, I am thinking it just does not have permission to save the file. right now the only way for someone to upload a file is to use a ftp program and log in.. can I hard code the user name and password into the php upload script so it will allow it to save the file.. OR Is it possible to create a php login first screen first, and when they login then they can upload the file into the folder. thanks Link to comment https://forums.phpfreaks.com/topic/153228-client-file-upload-button/#findComment-805516 Share on other sites More sharing options...
Spike121 Posted April 9, 2009 Share Posted April 9, 2009 Permissions on a FTP file are not actually PHP, but what you need to do (I think) is to use a FTP program such as FileZilla (downloaded free, you can google it), then connect to your FTP server, and right click the folder the files are being uploaded to (in this case, I think it's the customers folder?), and then click Permissions or something along the lines of that. Then set the permissions to 777, or tick all boxes. That should work. Link to comment https://forums.phpfreaks.com/topic/153228-client-file-upload-button/#findComment-805533 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.