onikboss Posted February 11, 2011 Share Posted February 11, 2011 I designed a web form that takes as input a file and that should upload that file on the server. The file is located on the client machine. The page containing the web form is handled by PHP script. I found out (reading 9483658954 forum topics so far) that there are 2 methods for getting a file uploaded. The first one is using FTP, and the second one using $_FILES variable. Unfortunately i have complains regarding both of the methods. Firstly, when attempting to upload the file using FTP it seems that rather the FTP server is calling "upload" a simple copy action (because the only successful thing i could do with FTP was to copy a file from location A to location B, both A and B being on the server) or I don't know to use FTP (which is probably the right answer). Then, when using $_FILES variable, I was forced to include ' enctype="multipart/form-data" ' in the form tag. After a long documentation I finally figured out that by including the enctype blah blah, the $_POST and $_FILES variables were NULL after the form was submitted.Still can't understand why! Are there any other methods for uploading a file from the client machine to the server? Can I get a competent script for this? Link to comment https://forums.phpfreaks.com/topic/227402-how-to-upload-file-from-client-to-server-using-php/ Share on other sites More sharing options...
litebearer Posted February 11, 2011 Share Posted February 11, 2011 enctype="multipart/form-data Works just fine, sooooo Post your code where we might discover the problem Link to comment https://forums.phpfreaks.com/topic/227402-how-to-upload-file-from-client-to-server-using-php/#findComment-1172959 Share on other sites More sharing options...
gizmola Posted February 11, 2011 Share Posted February 11, 2011 You may have left out a key detail. The form must use method="post"! If you neglected to include that, it could explain your results. This page has every thing you need to know to get your file upload working. http://us3.php.net/manual/en/features.file-upload.php Link to comment https://forums.phpfreaks.com/topic/227402-how-to-upload-file-from-client-to-server-using-php/#findComment-1172964 Share on other sites More sharing options...
onikboss Posted February 12, 2011 Author Share Posted February 12, 2011 this is the form: <form action="upload.php" method="post" name="upload" enctype="multipart/form-data"> Upload in category: <select name="category"> <option value="category">C1</option> </select> <br /> <br /> File: <input type="file" style=" width: 250px" name="path" /> <br /> <br /> <button type="submit" name="submit_upload">Upload</button> </form> and this is how i'm accessing the variables: if (isset($_POST['submit_upload'])) { if ($_POST['path']!="") { //upload can start //here i can't figure out what script to use, because both methods failed } else { //path invalid print '<div class="alert"><p><b>No file selected</b></p></div><br /><br />'; require("upload_form.html"); } } else { require('upload_form.html'); } the output is : "No file selected"! by the way...the form is stored into a separate file called "upload_form.html" I have all the source files on a free hosting server. If you, guys, need more details please let me know Link to comment https://forums.phpfreaks.com/topic/227402-how-to-upload-file-from-client-to-server-using-php/#findComment-1173179 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.