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.

Dani AI

Generated

A few practical points that fill gaps left by the earlier replies and make an uploader safe and reliable long-term.

Dreamweaver only builds the front end. A server that runs PHP (or another server-side language) is required to receive and move uploaded files. ’s starter script is a useful basis, but it assumes the right environment and misses some deployment and security checks that commonly trip up newcomers (as noted). Confirm the host actually serves PHP (a simple phpinfo page will show the PHP version and upload limits).

Common deployment and file‑management notes: save the handler with a .php extension in Dreamweaver, then publish it to the correct remote root (public_html, www, etc.) using FTP, the host’s File Manager (cPanel/Plesk), SSH, or Dreamweaver’s Files panel. To remove an unwanted uploader.php: delete it via an FTP client (FileZilla), the hosting control panel File Manager, SSH, or Dreamweaver’s remote Files view. A frequent problem is putting files in the wrong remote directory.

Configuration and security checklist that was missing from the thread: check php.ini limits (upload_max_filesize, post_max_size, max_execution_time); ensure the uploads directory is writable by the webserver user (prefer chown to that user and permissions like 755 or 775 — avoid 777 if possible); never trust client MIME types alone — validate extension and file headers (old .doc files use the Compound File magic bytes D0 CF 11 E0; .docx is a ZIP/PK container); generate safe unique filenames; store uploads outside webroot or disable script execution in the uploads folder to stop uploaded files from running.

Quick troubleshooting checklist: PHP enabled; form uses POST and multipart/form-data; handler is .php on the correct remote path; uploads folder exists and is writable; php.ini limits are sufficient; check $_FILES['error'] and server logs for failures. ’s code is a good starting point; combine it with these environment, permission and validation steps before allowing public uploads.

Recommended Answers

All 9 Replies

So are you saying that you already have an upload script but dont know how to implement?

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.

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.

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.

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

Disregard. I figured it out. Thanks.

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

How Can I do this but with pictures?? PLEASE HELP IT IS FOR A SCHOOL PROJECT!

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?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.