OtagoHarbour
Members-
Posts
118 -
Joined
-
Last visited
Content Type
Profiles
Forums
Events
Everything posted by OtagoHarbour
-
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.
-
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
-
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:
-
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.
-
loadXMLDoc loads unmodified version of modified XML file
OtagoHarbour replied to OtagoHarbour's topic in XML
Yes. That was the problem. Thanks again.- 4 replies
-
- loadXMLDoc
- XML
-
(and 1 more)
Tagged with:
-
loadXMLDoc loads unmodified version of modified XML file
OtagoHarbour replied to OtagoHarbour's topic in XML
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.- 4 replies
-
- loadXMLDoc
- XML
-
(and 1 more)
Tagged with:
-
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.
- 4 replies
-
- loadXMLDoc
- XML
-
(and 1 more)
Tagged with:
-
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.