Jump to content

neo71

New Members
  • Posts

    3
  • Joined

  • Last visited

neo71's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thak u!. users choose a category by a select: <fieldset> Sellct category:<br> <select name="siti" onchange="this.form.nome_mulino.disabled=(this.options[this.selectedIndex].value=='MOLINI')?false:true" > <option value="MOLINI" selected="selected">ACQUA, FORZA MOTRICE. I MOLINI, RISORSA DI IERI E DI DOMANI</option> <option value="VITA">LA VITA NEL FIUME</option> <option value="FIUMI">I NOSTRI FIUMI VISTI DALL’ALTO</option> Nome mulino<input type="text" name="nome_mulino" disabled="disabled" /> </select> </fieldset> $category = $_POST[‘siti’];
  2. I need to upload a file to a folder based on one of three possible categories $folder1= “uploads/categoryA/”; $folder2 = “uploads/categoryB/”; $folder3 = “uploads/categoryC/”; with a select I set the categories to the variable then I upload if (isset($_POST[‘btn-upload’])) { if (isset($_FILES[‘file’])) { move_uploaded_file($file_loc,$folder1.$final_file); } this works but I would like the file to be uploaded via $category in the corresponding $folder
  3. hi to everyone and sorry for my English. in a html form, a user can upload from one to four file intwo different category (A and B) <table> <tr> <td><b><i>Categoria a</i><b/> </td> <td><b><i>Categoria b</i><b/> </td> </tr> <tr> <td style="vertical-align: top; width: 475px;"><br /><b>File 1a<b/></td> <td style="vertical-align: top; width: 475px;"><br /><b>File 1b<b/></td> </tr> <tr> <td><br> <input name="file" type="file"> </td> <td><br> <input name="file1" type="file"></td> </tr> <tr> <td> Luogo dello scatto *:<br> <input name="luogo1" type="text"><br> </td> <td> Luogo dello scatto *:<br> <input name="luogo2" type="text"> <br> </td> </tr> <tr> <td> Titolo *:<br> <input name="titolo1" type="text"><br> </td> <td> Titolo *:<br> <input name="titolo2" type="text"> <br> </td> </tr> <tr> <td style="vertical-align: top; width: 475px;"><br /><b>File 2a<b/></td> <td style="vertical-align: top; width: 475px;"><br /><b>File 2b<b/></td> </tr> <tr> <td><br> <input name="file2" type="file"> </td> <td><br> <input name="file3" type="file"></td> </tr> <tr> <td> Luogo *:<br> <input name="luogo3" type="text"><br> </td> <td> Luogo *:<br> <input name="luogo4" type="text"> <br> </td> </tr> <tr> <td> Titolo *:<br> <input name="titolo3" type="text"><br> </td> <td> Titolo *:<br> <input name="titolo4" type="text"> <br> </td> </tr> they are then passed to the upload.php file ..... for each file: $file_1 = rand(1000,100000)."-".$_FILES['file']['name']; $file_1_loc = $_FILES['file']['tmp_name']; $file_1_size = $_FILES['file']['size']; $file_1_type = $_FILES['file']['type']; $folder1= "uploads/categoria_a/"; $file_2 = rand(1000,100000)."-".$_FILES['file1']['name']; $file_2_loc = $_FILES['file1']['tmp_name']; $file_2_size = $_FILES['file1']['size']; $file_2_type = $_FILES['file1']['type']; $folder2 = "uploads/categoria_b/"; and so on... then the upload... if (move_uploaded_file($file_1_loc,$folder1.$final_file_1) || move_uploaded_file($file_2_loc,$folder2.$final_file_2) || move_uploaded_file($file_3_loc,$folder1.$final_file_3) || move_uploaded_file($file_4_loc,$folder2.$final_file_4)) { $sql="INSERT INTO .. (here all the data entry part in the sql table that works..... ,,, ','$caricateil')"; mysql_query($sql); <script> alert("Invio dati eseguito correttamente. "); window.location.href='index.php?success'; </script> <?php } else { ?> <script> alert("Errore nell'invio dei dati"); window.history.back(1); </script> <?php } } } ...... well.. if I use the code if (move_uploaded_file($file_1_loc,$folder 1.$final_file_1) || move_uploaded_file($file_2_loc,$folder 2.$final_file_2 )|| move_uploaded_file($file_3_loc,$folder 1.$final_file_3) || move_uploaded_file($file_4_loc,$folder 2.$final_file_4)) { $sql="INSERT INTO ...... **Loads only the first of the 4 files** it finds even if the db is populated correctly with file name size.... If, on the other hand, I use if (move_uploaded_file($file_1_loc,$folder 1.$final_file_1) &&amp;move_uploaded_file($file_2_loc,$folder 2.$final_file_2) && move_uploaded_file($file_3_loc,$folder 1.$final_file_3) &&amp;move_uploaded_file($file_4_loc,$folder 2.$final_file_4)) Works... but only if all 4 files are present. However, a person can only upload one.. in position 1, 2, 3 or 4..... If one of the 4 is empty, the upload stops. I hope I explained myself.... If I load files 1, 3 and 4, load only the first... If I insert files 2 and 4, load only the 2 etc. And also from error even if it uploads the first files... I would like you to upload the files and continue the script regardless of which file is up-to-date... I hope I have been clear.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.