1

Can anyone help me with a upload-file function using Dreamweaver. I'm a real novice and would appreciate any help applying this function to pages created in Dreamweaver - server-side script, how to apply it and generally what I need to do.

6
Contributors
9
Replies
11
Views
10 Years
Discussion Span
Last Post by zslatcher
0

No. I've just created the base design in Dreamweaver, and created the form with upload button, but now I need some 'server-side' script to make it work. And the help option and Adobe support is useless! Appreciate any advice.

0

In dreamweaver, create a new php file. Clear all of the code out of the code view. Now click toggle plain text, copy and paste all of the following into dreamweaver:

<?php
      if(isset($_POST['submit'])){
      $numfilesuploaded = $_POST['numuploads'];
      $count = 1;
 
          while ($count <= $numfilesuploaded)
          {
                  $conname = "new_file".$count;

                  $filetype = $_FILES[$conname]['type'];
                 
                  $filename = $_FILES[$conname]['name'];
                  if ($filename != '')
                  {
                    if ($filetype == "application/msword" || $filetype=="application/vnd.openxmlformats-officedocument.wordprocessingml.document")
                    {
                        $maxfilesize = $_POST['maxsize'];
                        $filesize = $_FILES[$conname]['size'];
                        if($filesize <= $maxfilesize )
                        {
                              $randomdigit = rand(0000,9999);
                             
                              $newfilename = $randomdigit.$filename;
                              $source = $_FILES[$conname]['tmp_name'];
                              $target = "files/".$newfilename;
                              move_uploaded_file($source, $target);
                              echo $count." File uploaded | ";
                      
                        
                        }
                        else
                        {
                            echo $count." File is too big! 10MB limit! |";
                        
                        }
                    }
                    else
                    {
                        echo " The file is not a supported type |";
						echo $filetype;
                    }
                  }
          $count = $count + 1;
          }
      
      }
?>
<?php
    $numuploads = 1;
    $count = 1;
?>
<form action="<?php echo $_server['php-self'];  ?>" method="post" enctype="multipart/form-data" id="something" class="uniForm">
<?php
      while ($count <= $numuploads)
      {

?>
      <input name="new_file<?php echo $count; ?>" id="new_file<?php echo $count; ?>" size="30" type="file" class="fileUpload" />
      <?php
            $count = $count + 1;
      }
?>
      <input type = "hidden" name="maxsize" value = "10240000">
       <input type = "hidden" name="numuploads" value = "<?php echo $numuploads; ?>">
      <br>
      <button name="submit" type="submit" class="submitButton">Upload Files</button>

</form>

Name the above file uploader.php
Move the file to your server. In the same directory as the uploader.php file, create a new folder and name it files. Now go into your browser and test the uploader.php file.

0

Many thanks, much appreciated. I will give it a go, but as said, my background in print design and not web. I've no problem creating static pages, but when it comes to the back-end stuff, I'm pretty much lost. As soon as I've got it going, I will ping you back. Creating a php file in Dreamweaver is pretty straight forward I guess? Regards.

0

Thank you for this info. I think I am close but how do I created the submit button so the file will upload?

0

My GOODNESS !!!! I've been searching for an answer to this problem for a week and I've finally found it.

buddylee17 YOU ARE THE MAN !!!!

I just joined the site & am looking forward to sharing with you. Thanks a Million

0

In dreamweaver, create a new php file. Clear all of the code out of the code view. Now click toggle plain text, copy and paste all of the following into dreamweaver:

<?php
      if(isset($_POST['submit'])){
      $numfilesuploaded = $_POST['numuploads'];
      $count = 1;
 
          while ($count <= $numfilesuploaded)
          {
                  $conname = "new_file".$count;

                  $filetype = $_FILES[$conname]['type'];
                 
                  $filename = $_FILES[$conname]['name'];
                  if ($filename != '')
                  {
                    if ($filetype == "application/msword" || $filetype=="application/vnd.openxmlformats-officedocument.wordprocessingml.document")
                    {
                        $maxfilesize = $_POST['maxsize'];
                        $filesize = $_FILES[$conname]['size'];
                        if($filesize <= $maxfilesize )
                        {
                              $randomdigit = rand(0000,9999);
                             
                              $newfilename = $randomdigit.$filename;
                              $source = $_FILES[$conname]['tmp_name'];
                              $target = "files/".$newfilename;
                              move_uploaded_file($source, $target);
                              echo $count." File uploaded | ";
                      
                        
                        }
                        else
                        {
                            echo $count." File is too big! 10MB limit! |";
                        
                        }
                    }
                    else
                    {
                        echo " The file is not a supported type |";
						echo $filetype;
                    }
                  }
          $count = $count + 1;
          }
      
      }
?>
<?php
    $numuploads = 1;
    $count = 1;
?>
<form action="<?php echo $_server['php-self'];  ?>" method="post" enctype="multipart/form-data" id="something" class="uniForm">
<?php
      while ($count <= $numuploads)
      {

?>
      <input name="new_file<?php echo $count; ?>" id="new_file<?php echo $count; ?>" size="30" type="file" class="fileUpload" />
      <?php
            $count = $count + 1;
      }
?>
      <input type = "hidden" name="maxsize" value = "10240000">
       <input type = "hidden" name="numuploads" value = "<?php echo $numuploads; ?>">
      <br>
      <button name="submit" type="submit" class="submitButton">Upload Files</button>

</form>

Name the above file uploader.php
Move the file to your server. In the same directory as the uploader.php file, create a new folder and name it files. Now go into your browser and test the uploader.php file.

I can't get this file off my server. The uploader.php. How do I get it off my server?

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.