Jump to content


  • Posts

  • Joined

  • Last visited

About OtagoHarbour

  • Birthday 07/01/1955

Contact Methods

  • Website URL
  • ICQ

OtagoHarbour's Achievements


Member (2/7)



  1. I have figured out that it is not the length of the file names but the size of the files. The PHP post failed because the files were 11 MB each. Two of them exceeded the php.ini limit of 20 MB.
  2. I was not sure whether this question belongs here of in the PHP forum since my problem may be with one or the other or both. I use the following html and php code to select and upload multiple files.HTML <form action="uploadFiles.php" method="post" enctype="multipart/form-data"> <label for="file">Filename:</label> <input type="file" name="file[]" multiple="multiple"/></br> <input type="submit" name="submit[]" value="submit" /> </form> uploadFiles.php <?php if(isset($_POST['submit'])) { if ($_FILES["file[]"]["error"] > 0) { echo "Error: " . $_FILES["file[]"]["error"] . "<br>"; } else { $numFilesUploaded=count($_FILES['file']['name']); echo "No. files uploaded : ".$numFilesUploaded."<br><br>"; for ($inc=0; $inc<$numFilesUploaded; ++$inc){ echo "File " . $inc . ": " . $_FILES["file"]["name"][$inc] . "<br>"; echo "Upload: " . $_FILES["file"]["name"][$inc] . "<br>"; echo "Type: " . $_FILES["file"]["type"][$inc] . "<br>"; echo "Size: " . ($_FILES["file"]["size"][$inc] / 1024) . " kB<br>"; echo "Stored in: " . $_FILES["file"]["tmp_name"][$inc]; echo "<br><br>"; } } } ?> If I select 2 files, each having names of character length 8, the code works fine. However, when I select files with names of character length 32, $_POST is an empty array. What is the best way to upload multiple files where the file names may be long? I ran phpinfo() and it did indeed say "This server is protected with the Suhosin Patch 0.9.10 ..." Some people have suggested that it may be a problem with the file size. However, I never get to even try to upload files since the names are not properly passed to the PHP code if the filenames are too long. Also, I have modified /etc/php5/apache2/php.ini to allow the upload of files larger than the files I am trying to upload. Also, I do not have this problem if I shorten the names of the files I am having trouble with. Many thanks in advance for any help.
  3. I tried that code except without <!doctype html> since it is a PHP file. I found that if(isset($_POST['submit'])) returns false. I don't know why this is since this is my form code and I selected 2 files. <form action="uploadFiles.php" method="post" enctype="multipart/form-data"> <label for="file">Filename:</label> <input type="file" name="file[]" multiple /><br> <input type="submit" name="submit" value="submit" /></form> Thanks, OH
  4. Thank you for your reply but it still does not appear to be working properly. I tried echo "_FILES[file]: " . print_r($_FILES['file']) . "<br>"; if ($_FILES["file"]["error"][0] > 0) { echo "Error: " . $_FILES["file"]["error"][0] . "<br>"; // this would check for error only for that first image selced } else { echo "No. files uploaded : ".count($_FILES['file']['name'])."<br>"; echo "Upload: " . $_FILES["file"]["name"][0] . "<br>"; // this selects the name of the first image selected echo "Type: " . $_FILES["file"]["type"][0] . "<br>";// this selects the type of the first image selected echo "Size: " . ($_FILES["file"]["size"][0] / 1024) . " kB<br>"; // this gets the size of the first image selected echo "Stored in: " . $_FILES["file"]["tmp_name"][0]; // // this gets the temp_name of the first image selected } and got _Files[file]: 1No. files uploaded: 0Upload:Type:Size: 0 kBStored in:
  5. I am trying to modify the code given here to upload multiple files. The code I use is as follows. ?> <form action="uploadFiles.php" method="post" enctype="multipart/form-data"> <label for="file">Filename:</label> <input type="file" name="file[]" multiple><br> <input type="submit" name="submit" value="Submit"> </form><? uploadFiles.php has the following code <?php if ($_FILES["file"]["error"] > 0) { echo "Error: " . $_FILES["file"]["error"][0] . "<br>"; } else { echo "No. files uploaded : ".count($_FILES['file']['name'])."<br>"; echo "Upload: " . $_FILES["file"]["name"][0] . "<br>"; echo "Type: " . $_FILES["file"]["type"] . "<br>"; echo "Size: " . ($_FILES["file"]["size"] / 1024) . " kB<br>"; echo "Stored in: " . $_FILES["file"]["tmp_name"]; }?> I select 2 files in the browser window and get the following output. No. files uploaded: 0Upload:Type:Size: 0kBStored in: I cannot understand why I am getting 0 files when I selected 2 files. Thanks, OH.
  6. Yes. That was the problem. Thanks again.
  7. Sorry. I should have mentioned that I am doing everything in JavaScript with some HTML. However you are certainly right about the caching causing the problem. I put the following code <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" /><meta http-equiv="Pragma" content="no-cache" /> in the head section of index.html and that appears to have solved the problem. Thank you very much for you help,Peter.
  8. I used loadXMLDoc to load an XML file onto my web page. I then saved different contents to a file of the save name. When I reloaded the file with loadXMLDoc, I got the original contents instead of the new contents. I deleted the file and then save the new contents to the file with the same name. Reloading still gave me the old contents. I then changed the name of the file. This time loading the file with loadXMLDoc gave me the new contents. Does loadXMLDoc remember the contents that was loaded from a file with a given name and not bother reloading the contents if I present it with a file of the same name albeit different contents? After modifying the file, I looked at the XML code and the contents were modified after the first modification.
  9. I would like to use PHP to put a vertical space on a web page. echo "<br \><br \><br \><br \>"; works fine on FireFox but probably breaks several rules in relation to strict xhtml and may not work as well on other browsers. Is there are more standard/correct/robust way of doing this? Thanks,Peter.
  10. Thanks. I'll try that and see if it works. The problem with what I had initially was that I did not specify the contect so it took the default. Thanks,Peter.
  11. Someone gave me the answer. It should be <li><a href="">About</a></li>
  12. I tried chaning the php code to <li><a href="$_SERVER['']/">About</a></li> but now it tries to accesshttp://localhost//$_SERVER['']/ I want it to just try to access192.168.1.4/about.php without all the preceeding stuff. Thanks,Peter.
  13. I am hosting a web site from home. My system has two layers: a web server (running Ubuntu 11.04) that is port forwarded through port 80 and has only index.php on var/www and an application server (running Ubuntu 11.10) that has everything else and is set up to only talk to the web layer server. index.php has the following line of code. <li><a href="">About</a></li> This is a menu item that is supposed to call about.php which is located in var/www on the application server which has the local IP address However, when I click the button associated with this menu item, it tries to access http://localhost/ and gives the error message The requested URL / was not found on this server. If I go to the address box and manually delete the http://localhost/ part so the address box simply says then the about.php page on the application server shows up. Subsequently, when I click on a menu button associated with index.php then everything works fine. It seems like it starts by adding http://localhost/ to the specified address until I manualy delete it and then it leaves it out by default. The real problem comes when I try to access my site from another computer. I type in my domain name, say whatever.com, and the index.php page shows up. However when I click on the menu button, it tries to access http://whatever.com/...8.1.4/about.php and gives an error message. When I go to the URL box and manually delete http://whatever.com/, everything works fine. However I do not want the user to have to do this. Also, I am doing this from another computer on my home network so I am not sure what would happen from a remote computer. What is the best way to get the index.php file to simply use and not localhost/, whatever.com/ etc. Many thanks in advance,Peter.
  14. No worries. I sorted this out. I just needed to uninstall the old Apache.
  15. Thank you so much for your help. I fixed the validator problems and also added two tables, gradually adding what I needed to them and now the web page looks exactly as I would like it to look. Thanks again. The issue that I need to deal with now is that my web server is running Apache http://httpd.apache.....3/windows.html but it seems that I would need WAMP (for Windows) in order to use PHP. I have used WampServer http://www.wampserver.com/en/ in the past. My question is how do I get my web server to use WampServer instead of regular Apache? It is currently looking for my index.html file in the Apache directory and deploying it over the web using Apache. I was wondering if you could tell me how I could get it to use WampServer instead. Thanks again,Peter.
  • Create New...