Jump to content

jvargas

New Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Posts posted by jvargas

  1. Go to this website and use this PHP class it does all the uploading and resizing and more for you.

    http://www.verot.net/php_class_upload.htm

    The databse part you would need to write your own code but here is something I have put together using the above php class.

    // You will need to enter your databse information

    //Lets connect to the database.
    mysql_connect($server, $db_user, $db_pass) or die ("Database CONNECT Error");
    mysql_select_db($database) or die ('Could not select database $db_name: ' . mysql_error());


    error_reporting(E_ALL);

    // we first include the upload class, as we will need it here to deal with the uploaded file
    include('class.upload.php');


        // as it is multiple uploads, we will parse the $_FILES array to reorganize it into $files
    // my_field is the field name you give the your HTML form field
      $files = array();
        foreach ($_FILES['my_field'] as $k => $l) {
            foreach ($l as $i => $v) {
                if (!array_key_exists($i, $files))
                    $files[$i] = array();
                $files[$i][$k] = $v;
            }
        }

        // now we can loop through $files, and feed each element to the class
        foreach ($files as $file) {
       
            // we instanciate the class for each element of $file
            $execute = new Upload($file);
     
      // Check to see if files where uploaded
      if ($execute->uploaded) {
     
       
    // Run the first image function   
      $execute->auto_create_dir      = true; // automatically create the directory if it does not exists
      $execute->dir_auto_chmod      = true; // change the directory permission to writable
      $execute->image_resize        = true; // If "true" resize the picture
      $execute->image_x              = 480;  // The desired width of the resize - in this case X axis
      $execute->image_ratio_y        = true; // If "true" keep the resize aspect ratio ofthe "y" property
      $execute->file_safe_name      = true; // If "true" replace spaces in the file name with "_" underscores.
      $execute-> file_autorename    = false;// If"true" automatically renames the file if it already exists.
      $execute->file_overwrite      = true; // If the file already exists overwrite it
      $execute->allowed              = array('image/jpg','image/jpeg','image/gif'); // Which type of files are allowed
      $execute->image_convert        = 'jpg';
      $execute->Process('images/users'); // Directory where the large picture will be stored
     
      // If everythig was successful display the first messasge 
      if ($execute->processed) {
        echo 'everything seems OK';
      }
      // if there is an error, display the error
      else {
        echo 'error : ' . $execute->error;
      }
     
     
    // Run the second image function 
      $execute->auto_create_dir      = true; //===================================================================
      $execute->dir_auto_chmod      = true; //
      $execute->image_resize        = true; //
      $execute->image_x              = 100;  // -  read the first function for the explaination of these variables
      $execute->image_ratio_y        = true; //
      $execute->file_safe_name      = true; //
      $execute-> file_autorename    = false;//
      $execute->file_overwrite      = true; //
      $execute->allowed              = array('image/jpg','image/jpeg','image/gif');
      $execute->image_convert        = 'jpg'; //====================================================================
      $execute->Process('images/users/thumbs'); // Store the image in the users thumbs directory

      if ($execute->processed) {
        echo 'everything seems ok for the thumbs';

    $filename = $execute->file_dst_name; //Get the name of the file

    $execute->Clean();// Clean Up

    //Get the pictures info
    $query_album_info = "SELECT * FROM pictures WHERE username='$username'";
    $res_album_info = mysql_query($query_album_info) ;
    $album_info = mysql_fetch_assoc($res_album_info) ;
    $x = 0 ;

    while ($x <= 99 ) {
    $x++ ;
    if ($album_info['pub' . $x] == "") {
    $next_available = "pub" . $x ;
    $next_available_desc = "desc_pub" . $x ;
    break 1 ;
    }
    }


    //Wrtie filenames and description to the database.(table name is pictures)
    $query_album_update = "UPDATE pictures SET $next_available='$filename', $next_available_desc='$filename' WHERE username='$username'" ;
    $res_album_update = mysql_query($query_album_update) ;

      } else {
        echo 'error : ' . $execute->error;
      }
    }
    }

    Hope this helps.

  2. Hello everyone,

    First let me thank anyone who replies in advance.

    My dilema is as follows:
    I have an HTML form that sends information to a php script that writes an XML file for me. This is fine.

    The form contains 3 fields: id, path, name.

    What I need to do is continue to apend to the XML anytime the form is submited before the ending node.
    Here is an example:

    XML FILE

    <?xml version="1.0" encoding="UTF-8"?>
    <gallery>
    <album id="1" path="carShow" name="some auto show" />

    </gallery>

    Here is what I need to apend to the XML file:

    <?xml version="1.0" encoding="UTF-8"?>
    <gallery>
    <album id="1" path="carShow" name="some auto show" />

    [b][color=red]<album id="2" path="album" name="another album" />[/color][/b]  <--- Information from the HTML form added here before the ending node.

    </gallery> [b]<---- Ending node[/b]

    Is this possible?

    Thank you.
    Jay
×
×
  • 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.