Transfert de fichier problème

  • Bogey
  • Bogey
  • Genius
  • Avatar de l’utilisateur
  • Inscription: Juil 14, 2005
  • Messages: 8211
  • Loc: USA
  • Status: Offline

Message Mai 15th, 2009, 11:02 pm

Cela commence vraiment à me pisser off. Ive été à travailler sur ce pendant environ 2 heures :evil:

J'ai une forme qui Im utilisent pour transférer des fichiers de mon disque sur mon site (Pour la fonctionnalité avatar). J'ai eu la classe de le faire à partir de PHPCLASSES.ORG.

La partie qui est gênant moi est:
Code: [ Select ]
File: <input type="file" name="hd_avatar" id="hda" size="25" />

Et le PHP pour dire: (assez longue)
PHP Code: [ Select ]
<?php
class ucp {
   
    private $errors = 0;
   
    /*
     * function __construct( void )
     *
     * The construct function for the UCP class
     */
   
    function __construct()
    {
        if(!isset($_SESSION['user']))
        {
            header("LOCATION: index.php");
        }
    }
   
    /*
     * function submit_account( string $email, string $conemail, string $pass, string $conpass, string $ola, string $hda, string $web, string $ctitle, string $msn, string $signature, string $allow_email, string $show_email, string $contact_choice)
     *      @string $email - User's email
     *      @string $conemail -  Same user's email
     *      @string $pass - Users password
     *      @string $conpass -  User's password retyped for confirmation
     *      @string $ola - User's avatar local to the website
     *      @string $hda - User's avatar from user's computer
     *      @string $web - User's website
     *      @string $ctitle - User's custom title
     *      @string $msn - User's MSN
     *      @string $signature - User's signature
     *      @string $allow_email - User's choice wether or not they want to get email from other users
     *      @string $show_email - User's choice wether they want their email to be securely shown
     *      @string $contact_choice - User's contact choice. Possible values:
     *                  1: PM
     *                  2: Email
     *                  3: Either
     *      
     * Basically a construct function for the account form
     */
   
    function submit_account($email, $conemail, $pass, $conpass, $ola, $hd_avatar, $web, $ctitle, $msn, $signature, $allow_email, $show_email, $contact_choice)
    {
        global $db;
       
        // Initiating the return array
        $return = array();
       
        $reg_var = $db->_get_('email', USERS, array('UID' => $_SESSION['user']));
       
        if($email != $reg_var)
        {
            $return[] = $this->update_email($_SESSION['user'], $email, $conemail);
        }
       
        if(!empty($pass))
        {
            $return[] = $this->update_password($_SESSION['user'], $pass, $conpass);
        }
       
        $reg_var = $db->_get_('avatar', USERS, array('UID' => $_SESSION['user']));
        var_dump($_FILES['hd_avatar']);
        if(sizeof($_FILES['hd_avatar'][0]) > 0)
        {
            $return[] = $this->update_avatar($_SESSION['user'], $ola, $hd_avatar, $reg_var);
        }
       
        $reg_var = $db->_get_('website', USERS, array('UID' => $_SESSION['user']));
       
        if($web != $reg_var)
        {
            $return[] = $this->update_website($_SESSION['user'], $web);
        }
       
        $reg_var = $db->_get_('custom_title', USERS, array('UID' => $_SESSION['user']));
       
        if($ctitle != $reg_var)
        {
            $return[] = $this->update_custom_title($_SESSION['user'], $ctitle);
        }
       
        $reg_var = $db->_get_('MSN', USERS, array('UID' => $_SESSION['user']));
       
        if($msn != $reg_var)
        {
            $return[] = $this->update_msn($_SESSION['user'], $msn);
        }
       
        $reg_var = $db->_get_('signature', USERS, array('UID' => $_SESSION['user']));
       
        if($signature != $reg_var)
        {
            $return[] = $this->update_signature($_SESSION['user'], $signature);
        }
       
        if($allow_email != 0)
        {
            $return[] = $this->allow_email($_SESSION['user'], $allow_email);
        }
       
        if($show_email != 0)
        {
            $return[] = $this->show_email($_SESSION['user'], $show_email);
        }
       
        if($contact_choice != 0)
        {
            $return[] = $this->contact_choice($_SESSION['user'], $contact_choice);
        }
       
        // Returning the results
        if(sizeof($return) > 0)
        {
            if($this->errors > 0)
            {
                $type1 = ($errors > 1) ? "were" : 'was';
                $type2 = ($errors > 1) ? "'s" : null;
                $text = "<p>There $type1 $errors mistake$type2 in the form.</p>\n";
            }
            else
            {
                $text = "<p>Your form was successfully submitted and your profile was edited.</p>\n";
            }
            $text .= "                <ul>\n";
            foreach($return as $return_val)
            {
                $text .= "                    <li>$return_val</li>\n";
            }
            $text .= "                </ul>\n";
           
            return trim($text);
        }
        else
        {
            return "<p>No changes were made.</p>\n";
        }
    }
   
    function update_email($uid, $email, $conemail)
    {
        global $db, $regex;
       
        if($email != $conemail)
        {
            $this->errors +1;
            return "Your email does not match your confirmation email.";
            break;
        }
       
        if(!preg_match($regex['EMAIL'], $email) || !preg_match($regex['EMAIL'], $conemail))
        {
            $this->errors +1;
            return "Your email are of incorrect type.";
            break;
        }
       
        $sql = array(
            'email' => $email,
        );
       
        $sql = $db->build_update(USERS, $sql, array('UID' => $uid));
       
        if($db->set_result_resource($sql, true))
        {
            return "Email updated successfully";
        }
    }
   
    function update_password($uid, $pass, $conpass)
    {
        global $db;
       
        if($pass != $conpass)
        {
            $this->errors +1;
            return "Your password does not match your confirmation password.";
        }
       
        $sql = array(
            'password' => md5($pass),
        );
       
        $sql = $db->build_update(USERS, $sql, array('UID' => $uid));
       
        if($db->set_result_resource($sql, true))
        {
            return "Password updated successfully";
        }
    }
   
    function update_avatar($uid, $ola, $hda, $reg_val)
    {
        global $db;
       
        $handle = new upload($_FILES['hd_avatar']);
       
        $username = $db->_get_('USERNAME', USERS, array('UID' => $_SESSION['user']));
        $filed = "images/avatars/$username.JPG";
       
        $unlink = true;
       
        if(file_exists($filed))
        {
            if(unlink($filed))
            {
                $unlink = true;
            }
        }
       
        if($handle->uploaded && $unlink == true)
        {
            $handle->file_new_name_body = $username;
            $handle->file_new_name_ext = 'jpg';
            $handle->image_resize = true;
            $handle->image_x = 120;
            $handle->image_ratio_y = true;
            $handle->Process('images/avatars');
           
 
           
            if(!$handle->processed) {
                return $handle->error;
            }
           
            $handle-> Clean();
           
        } else {
            return $handle->error;
        }
       
        $sql = array(
            'avatar' => "$username.JPG",
        );
       
        $sql = $db->build_update(USERS, $sql, array('UID' => $uid));
       
        if($db->set_result_resource($sql, true))
        {
            return 'Your avatar was successfully updated.';
        }
    }
   
    function update_website($uid, $web)
    {
        global $db, $regex;
       
        $sql = array(
            'website' => $web,
        );
       
        $sql = $db->build_update(USERS, $sql, array('UID' => $uid));
       
        if($db->set_result_resource($sql, true))
        {
            return "Website updated successfully";
        }
    }
   
    function update_custom_title($uid, $ctitle)
    {
        global $db;
       
        $sql = array(
            'custom_title' => $ctitle,
        );
       
        $sql = $db->build_update(USERS, $sql, array('UID' => $uid));
       
        if($db->set_result_resource($sql, true))
        {
            return "Custom title updated successfully";
        }
    }
   
    function update_msn($uid, $msn)
    {
        global $db;
       
        $sql = array(
            'MSN' => $msn,
        );
       
        $sql = $db->build_update(USERS, $sql, array('UID' => $uid));
       
        if($db->set_result_resource($sql, true))
        {
            return "MSN updated successfully";
        }
    }
   
    function allow_email($uid, $allow_email)
    {
        global $db;
       
        $allow = (($allow_email == 1) ? 1 : 2);
       
        $sql = array(
            'allow_email' => $allow,
        );
       
        $sql = $db->build_update(USERS, $sql, array('UID' => $uid));
       
        if($db->set_result_resource($sql, true))
        {
            return "You're email is now " . (($allow == 1) ? "allowed" : "not allowed");
        }
    }
   
    function show_email($uid, $show_email)
    {
        global $db;
       
        $show = (($show_email == 1) ? 1 : 2);
       
        $sql = array(
            'show_email' => $show,
        );
       
        $sql = $db->build_update(USERS, $sql, array('UID' => $uid));
       
        if($db->set_result_resource($sql, true))
        {
            return "You're email is now " . (($show == 1) ? "public" : "not public");
        }
    }
   
    function contact_choice($uid, $contact_choice)
    {
        global $db;
       
        $choice = (($contact_choice == 1) ? 1 :
                  (($contact_choice == 2) ? 2 :
                  (($contact_choice == 3) ? 3 : 1)));
       
        $contact = (($contact_choice == 1) ? 'PM' :
                   (($contact_choice == 2) ? 'Email' :
                   (($contact_choice == 3) ? 'PM and/or Email' : 'PM')));
       
        $sql = array(
            'contact_type' => $choice,
        );
       
        $sql = $db->build_update(USERS, $sql, array('UID' => $uid));
       
        if($db->set_result_resource($sql, true))
        {
            return "You are going to be contacted by " . $contact . " from now on.";
        }
    }
   
    function update_signature($uid, $signature)
    {
        global $db;
       
        $sql = array(
            'signature' => mysql_real_escape_string($signature),
        );
       
        $sql = $db->build_update(USERS, $sql, array('UID' => $uid));
       
        if($db->set_result_resource($sql, true))
        {
            return "You're signature was updated.";
        }
    }
}
  1. <?php
  2. class ucp {
  3.    
  4.     private $errors = 0;
  5.    
  6.     /*
  7.      * function __construct( void )
  8.      *
  9.      * The construct function for the UCP class
  10.      */
  11.    
  12.     function __construct()
  13.     {
  14.         if(!isset($_SESSION['user']))
  15.         {
  16.             header("LOCATION: index.php");
  17.         }
  18.     }
  19.    
  20.     /*
  21.      * function submit_account( string $email, string $conemail, string $pass, string $conpass, string $ola, string $hda, string $web, string $ctitle, string $msn, string $signature, string $allow_email, string $show_email, string $contact_choice)
  22.      *      @string $email - User's email
  23.      *      @string $conemail -  Same user's email
  24.      *      @string $pass - Users password
  25.      *      @string $conpass -  User's password retyped for confirmation
  26.      *      @string $ola - User's avatar local to the website
  27.      *      @string $hda - User's avatar from user's computer
  28.      *      @string $web - User's website
  29.      *      @string $ctitle - User's custom title
  30.      *      @string $msn - User's MSN
  31.      *      @string $signature - User's signature
  32.      *      @string $allow_email - User's choice wether or not they want to get email from other users
  33.      *      @string $show_email - User's choice wether they want their email to be securely shown
  34.      *      @string $contact_choice - User's contact choice. Possible values:
  35.      *                  1: PM
  36.      *                  2: Email
  37.      *                  3: Either
  38.      *      
  39.      * Basically a construct function for the account form
  40.      */
  41.    
  42.     function submit_account($email, $conemail, $pass, $conpass, $ola, $hd_avatar, $web, $ctitle, $msn, $signature, $allow_email, $show_email, $contact_choice)
  43.     {
  44.         global $db;
  45.        
  46.         // Initiating the return array
  47.         $return = array();
  48.        
  49.         $reg_var = $db->_get_('email', USERS, array('UID' => $_SESSION['user']));
  50.        
  51.         if($email != $reg_var)
  52.         {
  53.             $return[] = $this->update_email($_SESSION['user'], $email, $conemail);
  54.         }
  55.        
  56.         if(!empty($pass))
  57.         {
  58.             $return[] = $this->update_password($_SESSION['user'], $pass, $conpass);
  59.         }
  60.        
  61.         $reg_var = $db->_get_('avatar', USERS, array('UID' => $_SESSION['user']));
  62.         var_dump($_FILES['hd_avatar']);
  63.         if(sizeof($_FILES['hd_avatar'][0]) > 0)
  64.         {
  65.             $return[] = $this->update_avatar($_SESSION['user'], $ola, $hd_avatar, $reg_var);
  66.         }
  67.        
  68.         $reg_var = $db->_get_('website', USERS, array('UID' => $_SESSION['user']));
  69.        
  70.         if($web != $reg_var)
  71.         {
  72.             $return[] = $this->update_website($_SESSION['user'], $web);
  73.         }
  74.        
  75.         $reg_var = $db->_get_('custom_title', USERS, array('UID' => $_SESSION['user']));
  76.        
  77.         if($ctitle != $reg_var)
  78.         {
  79.             $return[] = $this->update_custom_title($_SESSION['user'], $ctitle);
  80.         }
  81.        
  82.         $reg_var = $db->_get_('MSN', USERS, array('UID' => $_SESSION['user']));
  83.        
  84.         if($msn != $reg_var)
  85.         {
  86.             $return[] = $this->update_msn($_SESSION['user'], $msn);
  87.         }
  88.        
  89.         $reg_var = $db->_get_('signature', USERS, array('UID' => $_SESSION['user']));
  90.        
  91.         if($signature != $reg_var)
  92.         {
  93.             $return[] = $this->update_signature($_SESSION['user'], $signature);
  94.         }
  95.        
  96.         if($allow_email != 0)
  97.         {
  98.             $return[] = $this->allow_email($_SESSION['user'], $allow_email);
  99.         }
  100.        
  101.         if($show_email != 0)
  102.         {
  103.             $return[] = $this->show_email($_SESSION['user'], $show_email);
  104.         }
  105.        
  106.         if($contact_choice != 0)
  107.         {
  108.             $return[] = $this->contact_choice($_SESSION['user'], $contact_choice);
  109.         }
  110.        
  111.         // Returning the results
  112.         if(sizeof($return) > 0)
  113.         {
  114.             if($this->errors > 0)
  115.             {
  116.                 $type1 = ($errors > 1) ? "were" : 'was';
  117.                 $type2 = ($errors > 1) ? "'s" : null;
  118.                 $text = "<p>There $type1 $errors mistake$type2 in the form.</p>\n";
  119.             }
  120.             else
  121.             {
  122.                 $text = "<p>Your form was successfully submitted and your profile was edited.</p>\n";
  123.             }
  124.             $text .= "                <ul>\n";
  125.             foreach($return as $return_val)
  126.             {
  127.                 $text .= "                    <li>$return_val</li>\n";
  128.             }
  129.             $text .= "                </ul>\n";
  130.            
  131.             return trim($text);
  132.         }
  133.         else
  134.         {
  135.             return "<p>No changes were made.</p>\n";
  136.         }
  137.     }
  138.    
  139.     function update_email($uid, $email, $conemail)
  140.     {
  141.         global $db, $regex;
  142.        
  143.         if($email != $conemail)
  144.         {
  145.             $this->errors +1;
  146.             return "Your email does not match your confirmation email.";
  147.             break;
  148.         }
  149.        
  150.         if(!preg_match($regex['EMAIL'], $email) || !preg_match($regex['EMAIL'], $conemail))
  151.         {
  152.             $this->errors +1;
  153.             return "Your email are of incorrect type.";
  154.             break;
  155.         }
  156.        
  157.         $sql = array(
  158.             'email' => $email,
  159.         );
  160.        
  161.         $sql = $db->build_update(USERS, $sql, array('UID' => $uid));
  162.        
  163.         if($db->set_result_resource($sql, true))
  164.         {
  165.             return "Email updated successfully";
  166.         }
  167.     }
  168.    
  169.     function update_password($uid, $pass, $conpass)
  170.     {
  171.         global $db;
  172.        
  173.         if($pass != $conpass)
  174.         {
  175.             $this->errors +1;
  176.             return "Your password does not match your confirmation password.";
  177.         }
  178.        
  179.         $sql = array(
  180.             'password' => md5($pass),
  181.         );
  182.        
  183.         $sql = $db->build_update(USERS, $sql, array('UID' => $uid));
  184.        
  185.         if($db->set_result_resource($sql, true))
  186.         {
  187.             return "Password updated successfully";
  188.         }
  189.     }
  190.    
  191.     function update_avatar($uid, $ola, $hda, $reg_val)
  192.     {
  193.         global $db;
  194.        
  195.         $handle = new upload($_FILES['hd_avatar']);
  196.        
  197.         $username = $db->_get_('USERNAME', USERS, array('UID' => $_SESSION['user']));
  198.         $filed = "images/avatars/$username.JPG";
  199.        
  200.         $unlink = true;
  201.        
  202.         if(file_exists($filed))
  203.         {
  204.             if(unlink($filed))
  205.             {
  206.                 $unlink = true;
  207.             }
  208.         }
  209.        
  210.         if($handle->uploaded && $unlink == true)
  211.         {
  212.             $handle->file_new_name_body = $username;
  213.             $handle->file_new_name_ext = 'jpg';
  214.             $handle->image_resize = true;
  215.             $handle->image_x = 120;
  216.             $handle->image_ratio_y = true;
  217.             $handle->Process('images/avatars');
  218.            
  219.  
  220.            
  221.             if(!$handle->processed) {
  222.                 return $handle->error;
  223.             }
  224.            
  225.             $handle-> Clean();
  226.            
  227.         } else {
  228.             return $handle->error;
  229.         }
  230.        
  231.         $sql = array(
  232.             'avatar' => "$username.JPG",
  233.         );
  234.        
  235.         $sql = $db->build_update(USERS, $sql, array('UID' => $uid));
  236.        
  237.         if($db->set_result_resource($sql, true))
  238.         {
  239.             return 'Your avatar was successfully updated.';
  240.         }
  241.     }
  242.    
  243.     function update_website($uid, $web)
  244.     {
  245.         global $db, $regex;
  246.        
  247.         $sql = array(
  248.             'website' => $web,
  249.         );
  250.        
  251.         $sql = $db->build_update(USERS, $sql, array('UID' => $uid));
  252.        
  253.         if($db->set_result_resource($sql, true))
  254.         {
  255.             return "Website updated successfully";
  256.         }
  257.     }
  258.    
  259.     function update_custom_title($uid, $ctitle)
  260.     {
  261.         global $db;
  262.        
  263.         $sql = array(
  264.             'custom_title' => $ctitle,
  265.         );
  266.        
  267.         $sql = $db->build_update(USERS, $sql, array('UID' => $uid));
  268.        
  269.         if($db->set_result_resource($sql, true))
  270.         {
  271.             return "Custom title updated successfully";
  272.         }
  273.     }
  274.    
  275.     function update_msn($uid, $msn)
  276.     {
  277.         global $db;
  278.        
  279.         $sql = array(
  280.             'MSN' => $msn,
  281.         );
  282.        
  283.         $sql = $db->build_update(USERS, $sql, array('UID' => $uid));
  284.        
  285.         if($db->set_result_resource($sql, true))
  286.         {
  287.             return "MSN updated successfully";
  288.         }
  289.     }
  290.    
  291.     function allow_email($uid, $allow_email)
  292.     {
  293.         global $db;
  294.        
  295.         $allow = (($allow_email == 1) ? 1 : 2);
  296.        
  297.         $sql = array(
  298.             'allow_email' => $allow,
  299.         );
  300.        
  301.         $sql = $db->build_update(USERS, $sql, array('UID' => $uid));
  302.        
  303.         if($db->set_result_resource($sql, true))
  304.         {
  305.             return "You're email is now " . (($allow == 1) ? "allowed" : "not allowed");
  306.         }
  307.     }
  308.    
  309.     function show_email($uid, $show_email)
  310.     {
  311.         global $db;
  312.        
  313.         $show = (($show_email == 1) ? 1 : 2);
  314.        
  315.         $sql = array(
  316.             'show_email' => $show,
  317.         );
  318.        
  319.         $sql = $db->build_update(USERS, $sql, array('UID' => $uid));
  320.        
  321.         if($db->set_result_resource($sql, true))
  322.         {
  323.             return "You're email is now " . (($show == 1) ? "public" : "not public");
  324.         }
  325.     }
  326.    
  327.     function contact_choice($uid, $contact_choice)
  328.     {
  329.         global $db;
  330.        
  331.         $choice = (($contact_choice == 1) ? 1 :
  332.                   (($contact_choice == 2) ? 2 :
  333.                   (($contact_choice == 3) ? 3 : 1)));
  334.        
  335.         $contact = (($contact_choice == 1) ? 'PM' :
  336.                    (($contact_choice == 2) ? 'Email' :
  337.                    (($contact_choice == 3) ? 'PM and/or Email' : 'PM')));
  338.        
  339.         $sql = array(
  340.             'contact_type' => $choice,
  341.         );
  342.        
  343.         $sql = $db->build_update(USERS, $sql, array('UID' => $uid));
  344.        
  345.         if($db->set_result_resource($sql, true))
  346.         {
  347.             return "You are going to be contacted by " . $contact . " from now on.";
  348.         }
  349.     }
  350.    
  351.     function update_signature($uid, $signature)
  352.     {
  353.         global $db;
  354.        
  355.         $sql = array(
  356.             'signature' => mysql_real_escape_string($signature),
  357.         );
  358.        
  359.         $sql = $db->build_update(USERS, $sql, array('UID' => $uid));
  360.        
  361.         if($db->set_result_resource($sql, true))
  362.         {
  363.             return "You're signature was updated.";
  364.         }
  365.     }
  366. }

Je veux faire la chose fichier avatar facultative...Je peux soit faire le script ignorer l'avatar si sa rempli ou non, ou faire il impose à chaque fois que le formulaire est rempli po j'ai obtenu les autres en option (Sur changement de valeur par défaut), mais le sh * t avatar me rend Nuts!

J'ai essayé de faire ce qui suit pour voir si l'avatar est rempli, mais je suppose que le type d'entrée "Fichier" ne rien envoyer via $ _POST, qui est muet, mais $ _POST [ "hd_avatar"] [0] (même si il donne 0 quand le champ n'est pas rempli et 7 [ou autre] lorsque le combler est rempli) ne fonctionne pas...qui rend le script ignorer l'avatar entièrement gif "alt =": x "title =" Mad ">

Code: [ Select ]
if(count($_FILES['hd_avatar']['name']) > 0)
{
    $return[] = $this->update_avatar($_SESSION['user'], $ola, $hd_avatar, $reg_var);
}
  1. if(count($_FILES['hd_avatar']['name']) > 0)
  2. {
  3.     $return[] = $this->update_avatar($_SESSION['user'], $ola, $hd_avatar, $reg_var);
  4. }


Aide à ce sujet serait grandement apprécié. Merci.
"Bring forth therefore fruits meet for repentance:" Matthew 3:8
  • Anonymous
  • Bot
  • No Avatar
  • Inscription: 25 Feb 2008
  • Messages: ?
  • Loc: Ozzuland
  • Status: Online

Message Mai 15th, 2009, 11:02 pm

  • Bogey
  • Bogey
  • Genius
  • Avatar de l’utilisateur
  • Inscription: Juil 14, 2005
  • Messages: 8211
  • Loc: USA
  • Status: Offline

Message Mai 15th, 2009, 11:13 pm

Nevermind, le texte suivant a finalement fait l'affaire. About time I tried that freaking :lol:
Code: [ Select ]
if(!empty($_FILES['hd_avatar']['name']))
{
    $return[] = $this->update_avatar($_SESSION['user'], $ola, $hd_avatar, $reg_var);
}
  1. if(!empty($_FILES['hd_avatar']['name']))
  2. {
  3.     $return[] = $this->update_avatar($_SESSION['user'], $ola, $hd_avatar, $reg_var);
  4. }

Bien que je ne vois pas comment l'autre n'a pas fonctionné...

Maintenant, j'ai besoin de trouver un moyen de télécharger des images depuis d'autres sites ( http://www.wedevoy.com/images/image.jpg ), Plutôt que de toujours partir du disque dur. (Aussi avancés que la classe je me suis dit, il ne le fait pas :shock:
"Bring forth therefore fruits meet for repentance:" Matthew 3:8
  • Bogey
  • Bogey
  • Genius
  • Avatar de l’utilisateur
  • Inscription: Juil 14, 2005
  • Messages: 8211
  • Loc: USA
  • Status: Offline

Message Mai 16th, 2009, 7:33 am

Ce qui suit ne fait pas le tour.
Code: [ Select ]
$target_path = "images/avatars/";

$target_path = $target_path . basename($ola);

if(move_uploaded_file($ola, $target_path))
{
    return "The file ". basename($ola). " has been uploaded";
}
else
{
    return "There was an error uploading the file, please try again!";
}
  1. $target_path = "images/avatars/";
  2. $target_path = $target_path . basename($ola);
  3. if(move_uploaded_file($ola, $target_path))
  4. {
  5.     return "The file ". basename($ola). " has been uploaded";
  6. }
  7. else
  8. {
  9.     return "There was an error uploading the file, please try again!";
  10. }
"Bring forth therefore fruits meet for repentance:" Matthew 3:8
  • joebert
  • Sledgehammer
  • Genius
  • No Avatar
  • Inscription: Fév 10, 2004
  • Messages: 13455
  • Loc: Florida
  • Status: Offline

Message Mai 16th, 2009, 10:16 am

Doesnt faire l'affaire pour quoi?

Im not sure si youve a frappé un problème avec les fichiers téléchargés via <input type="file/> ou si youve passé à télécharger à partir du serveur distant. :scratchhead:
Strong with this one, the sudo is.
  • Bogey
  • Bogey
  • Genius
  • Avatar de l’utilisateur
  • Inscription: Juil 14, 2005
  • Messages: 8211
  • Loc: USA
  • Status: Offline

Message Mai 16th, 2009, 2:36 pm

Oh, Ive a obtenu le chargement VIA <input type="file"/> travail, j'ai besoin de télécharger depuis un serveur distant ( http://www.domain.com/images/image.jpg ).
"Bring forth therefore fruits meet for repentance:" Matthew 3:8
  • SpooF
  • ٩๏̯͡๏۶
  • Bronze Member
  • Avatar de l’utilisateur
  • Inscription: Mai 22, 2004
  • Messages: 3415
  • Loc: Richland, WA
  • Status: Offline

Message Mai 16th, 2009, 2:55 pm

Ce n'est probablement pas le meilleur moyen d'aller à ce sujet, mais ma première pensée a été seulement de lancer une commande via wget exec . Vous pouvez utiliser l'option-P pour spécifier où vous voulez télécharger le fichier.
#define NULL (::rand() % 2)
  • Bogey
  • Bogey
  • Genius
  • Avatar de l’utilisateur
  • Inscription: Juil 14, 2005
  • Messages: 8211
  • Loc: USA
  • Status: Offline

Message Mai 16th, 2009, 2:56 pm

SpooF a écrit:
Ce n'est probablement pas le meilleur moyen d'aller à ce sujet, mais ma première pensée a été seulement de lancer une commande via wget exec

Désolé pour mon ignorance, mais ce que je vais de commande à utiliser? Je n'ai jamais vraiment utilisé CMD ou linux trucs et ne savent pas où trouver les commandes. Merci.
"Bring forth therefore fruits meet for repentance:" Matthew 3:8
  • SpooF
  • ٩๏̯͡๏۶
  • Bronze Member
  • Avatar de l’utilisateur
  • Inscription: Mai 22, 2004
  • Messages: 3415
  • Loc: Richland, WA
  • Status: Offline

Message Mai 16th, 2009, 3:02 pm

«wget» est un programme en ligne de commande qui retreives fichiers d'un serveur Web.

Usage:
Code: [ Select ]
wget http://domain.com/somefile.etc


Vous seriez probablement faire quelque chose comme.
Code: [ Select ]
exec('wget -P /your/absolute/path/goes/here/ '.$url);


pas sûr à 100% si cela va fonctionner.

Vous pourriez également être en mesure d'utiliser http://us3.php.net/curl
#define NULL (::rand() % 2)
  • Bogey
  • Bogey
  • Genius
  • Avatar de l’utilisateur
  • Inscription: Juil 14, 2005
  • Messages: 8211
  • Loc: USA
  • Status: Offline

Message Mai 16th, 2009, 8:09 pm

SpooF a écrit:
«wget» est un programme en ligne de commande qui retreives fichiers d'un serveur Web.

Usage:
Code: [ Select ]
wget http://domain.com/somefile.etc


Vous seriez probablement faire quelque chose comme.
Code: [ Select ]
exec('wget -P /your/absolute/path/goes/here/ '.$url);


pas sûr à 100% si cela va fonctionner.

Comment serais-je capable de renommer ce fichier et le déplacer vers un répertoire donné, et remplacez le fichier avec le même nom si elle existe?
"Bring forth therefore fruits meet for repentance:" Matthew 3:8
  • SpooF
  • ٩๏̯͡๏۶
  • Bronze Member
  • Avatar de l’utilisateur
  • Inscription: Mai 22, 2004
  • Messages: 3415
  • Loc: Richland, WA
  • Status: Offline

Message Mai 16th, 2009, 9:50 pm

Eh bien, vous pouvez le télécharger à n'importe quel dossier que vous voulez, et vous pouvez facilement le renommer via renommer -- http://us2.php.net/rename
#define NULL (::rand() % 2)
  • Bogey
  • Bogey
  • Genius
  • Avatar de l’utilisateur
  • Inscription: Juil 14, 2005
  • Messages: 8211
  • Loc: USA
  • Status: Offline

Message Mai 16th, 2009, 10:09 pm

SpooF a écrit:
Eh bien, vous pouvez le télécharger à n'importe quel dossier que vous voulez, et vous pouvez facilement le renommer via renommer -- http://us2.php.net/rename

Merci, je vais essayer :D

Juste une chose, comment puis-je convertir un fichier jpg à? Tout fichier image? Je ne sais pas ce que ce serait que je ne sais pas ce que l'utilisateur se présenter, mais jaimerais savoir comment convertir les images pour les jpg?
"Bring forth therefore fruits meet for repentance:" Matthew 3:8
  • SpooF
  • ٩๏̯͡๏۶
  • Bronze Member
  • Avatar de l’utilisateur
  • Inscription: Mai 22, 2004
  • Messages: 3415
  • Loc: Richland, WA
  • Status: Offline

Message Mai 16th, 2009, 11:11 pm

http://us3.php.net/manual/en/book.image.php
#define NULL (::rand() % 2)

Afficher de l'information

  • Total des messages de ce sujet: 12 messages
  • Utilisateurs parcourant ce forum: Aucun utilisateur enregistré et 134 invités
  • Vous ne pouvez pas poster de nouveaux sujets
  • Vous ne pouvez pas répondre aux sujets
  • Vous ne pouvez pas éditer vos messages
  • Vous ne pouvez pas supprimer vos messages
  • Vous ne pouvez pas joindre des fichiers
 
 

© 2011 Unmelted, LLC. Ozzu® est une marque déposée de Unmelted, LLC