bmbc Posted April 19, 2006 Share Posted April 19, 2006 This is the html part which I'm sure is not right:<form action="upload.php" method="post" enctype="multipart/form-data"><p>name:<input type="text" name="name[]" /></p><p>email:<input type="text" name="name[]" /></p><p>phone:<input type="text" name="name[]" /></p><p>choose area: <select name="area" size="1"> <option>Canberra Inner North</option> <option>Canberra Belconnen</option> <option>Canberra Gungahlin and Hall</option> <option>Canberra Inner South</option> <option>Canberra Weston Creek</option> <option>Canberra Woden Valley</option> <option>Canberra Tuggeranong</option> <option>Queanbeyan</option></select></p><p>property address:<input type="text" name="name[]" /></p><p>suburb name:<input name="suburb[]" type="text" id="suburb" size="8" maxlength="12" /><p>property type:<input name="suburb[]" type="text" id="suburb" size="8" maxlength="12" /><p>energy rating:<input name="number[]" type="text" size="5" maxlength="10" /><p>bedrooms:<input name="number[]" type="text" size="5" maxlength="10" /><p>block size: <input name="number[]" type="text" size="5" maxlength="10" /><p> property description:<br/><textarea name="describe" cols="60" rows="18">Please type no more than the approx. 200 words, deleting this message first.</textarea></p><p>Pictures:<br/><input type="file" name="pictures[]" /><br/><input type="file" name="pictures[]" /><br/><input type="file" name="pictures[]" /><br/><input type="file" name="pictures[]" /><br/><input type="file" name="pictures[]" /><input type="submit" value="Send" /></p></form>and this is the php part:<?phpforeach ($_FILES["pictures"]["error"] as $key => $error) { if ($error == UPLOAD_ERR_OK) { $tmp_name = $_FILES["pictures"]["tmp_name"][$key]; $name = $_FILES["pictures"]["name"][$key]; move_uploaded_file($tmp_name, "data/$name"); }}?>None of which works :(Any help really appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/7813-upload-multiple-file-type-form/ Share on other sites More sharing options...
poirot Posted April 19, 2006 Share Posted April 19, 2006 The HTML seems to be OK, for the PHP part, you can use this:[code]for ($k=0; $k<count($_FILES['pictures']['name']); $k++) { if ($_FILES['pictures']['error'][$k] == '0') { if (move_uploaded_file($_FILES['pictures']['tmp_name'][$k], 'uploads/' . $_FILES['pictures']['name'][$k])) { echo 'File ' . ($k+1) . ' uploaded successfully' . '<br />'; } }}[/code] Quote Link to comment https://forums.phpfreaks.com/topic/7813-upload-multiple-file-type-form/#findComment-28474 Share on other sites More sharing options...
bmbc Posted April 19, 2006 Author Share Posted April 19, 2006 <?phpfor ($k=0; $k<count($_FILES['pictures']['name']); $k++) { if ($_FILES['pictures']['error'][$k] == '0') { if (move_uploaded_file($_FILES['pictures']['tmp_name'][$k], 'uploads/' . $_FILES['pictures']['name'][$k])) { echo 'File ' . ($k+1) . ' uploaded successfully' . '<br />'; } }}?>That is your code above? I renamed this one upload2.php and changed the link in the htm file butI'm getting this error:Warning: move_uploaded_file(uploads/claw.gif): failed to open stream: No such file or directory in /home/l/lukem/www/upload2.php on line 6Warning: move_uploaded_file(): Unable to move '/home/l/lukem/www/upload/phphR7nZH' to 'uploads/claw.gif' in /home/l/lukem/www/upload2.php on line 6Thanks for your help and hope you can see my error this time. Quote Link to comment https://forums.phpfreaks.com/topic/7813-upload-multiple-file-type-form/#findComment-28475 Share on other sites More sharing options...
poirot Posted April 19, 2006 Share Posted April 19, 2006 Well, try this:[code]$updir = '/home/l/lukem/www/uploads/'for ($k=0; $k<count($_FILES['pictures']['name']); $k++) { if ($_FILES['pictures']['error'][$k] == '0') { if (move_uploaded_file($_FILES['pictures']['tmp_name'][$k], $updir . basename($_FILES['pictures']['name'][$k]))) { echo 'File ' . ($k+1) . ' uploaded successfully' . '<br />'; } }}[/code] Quote Link to comment https://forums.phpfreaks.com/topic/7813-upload-multiple-file-type-form/#findComment-28617 Share on other sites More sharing options...
bmbc Posted April 20, 2006 Author Share Posted April 20, 2006 Hi poirot,Here is where my form is that I'm practising on trying to make work:[a href=\"http://www.yabbit.net/myuploadform.htm\" target=\"_blank\"]http://www.yabbit.net/myuploadform.htm[/a](I have no idea why there is a text field right up the top when I can't see it in the htm but anyway the formjust doesn't work)And then I changed the upload.php to what you gave me:[code]<?php$updir = '/home/l/lukem/www/uploads/'for ($k=0; $k<count($_FILES['pictures']['name']); $k++) { if ($_FILES['pictures']['error'][$k] == '0') { if (move_uploaded_file($_FILES['pictures']['tmp_name'][$k], $updir . basename($_FILES['pictures']['name'][$k]))) { echo 'File ' . ($k+1) . ' uploaded successfully' . '<br />'; } }}?> [/code]And this is the error msg I get:Parse error: syntax error, unexpected T_FOR in /home/l/lukem/www/upload.php on line 5Also because I have radio buttons and text fields and text files as well as pictures etc to upload, my phpdoesn't reflect that or even point to a error and success page.Thx again. Quote Link to comment https://forums.phpfreaks.com/topic/7813-upload-multiple-file-type-form/#findComment-28859 Share on other sites More sharing options...
poirot Posted April 20, 2006 Share Posted April 20, 2006 Wops, forgot the semi-colon:[code]<?php$updir = '/home/l/lukem/www/uploads/';for ($k=0; $k<count($_FILES['pictures']['name']); $k++) { if ($_FILES['pictures']['error'][$k] == '0') { if (move_uploaded_file($_FILES['pictures']['tmp_name'][$k], $updir . basename($_FILES['pictures']['name'][$k]))) { echo 'File ' . ($k+1) . ' uploaded successfully' . '<br />'; } }}[/code]?> Quote Link to comment https://forums.phpfreaks.com/topic/7813-upload-multiple-file-type-form/#findComment-28863 Share on other sites More sharing options...
bmbc Posted April 20, 2006 Author Share Posted April 20, 2006 Thanks but it still doesn't work , no error now just no action- no files found in uploads folder after submit. Quote Link to comment https://forums.phpfreaks.com/topic/7813-upload-multiple-file-type-form/#findComment-28874 Share on other sites More sharing options...
bmbc Posted April 20, 2006 Author Share Posted April 20, 2006 Hi again ,I spent from 8am till 8pm today working with code and actually now that I think of it I've been doing that for the last three days plus dreaming about code solutions! ARGHH - I've come to the conclusion that either I am incredibly dumb or I'm trying to understand something which would take at least three months of studying(for me at least or I'm thinking maybe never will I comprehend it).Anyway, what I have worked out is there is a script in phpformgen that easily creates db tables but nothing else; a quick script at php will upload multiple files to your server folder but nothing else and dodupload will upload files as well but with the added benefit of restricting upload file size without my service provider's safe mode stopping it!But none of it is good :( because I want a php script that will execute my files text and images to a folder on my site from the htm form I've already created and on top of it all I dream of having one that will automatically resize input images so no mucking around in photoshop with ppl uploading absurd file size formats. It would be a bonus to then have all this recorded in mysql db. Pathetically I can only come up with the htm form :((My business idea is quickly fading away. All for one form. *vicious* Quote Link to comment https://forums.phpfreaks.com/topic/7813-upload-multiple-file-type-form/#findComment-29004 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.