Transfert de fichier problème
- Bogey
- Bogey


- Inscription: Juil 14, 2005
- Messages: 8211
- Loc: USA
- Status: Offline
Cela commence vraiment à me pisser off. Ive été à travailler sur ce pendant environ 2 heures 
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:
Et le PHP pour dire: (assez longue)
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 ">
Aide à ce sujet serait grandement apprécié. Merci.
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.";
}
}
}
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.";
}
}
}
- <?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.";
- }
- }
- }
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);
}
{
$return[] = $this->update_avatar($_SESSION['user'], $ola, $hd_avatar, $reg_var);
}
- if(count($_FILES['hd_avatar']['name']) > 0)
- {
- $return[] = $this->update_avatar($_SESSION['user'], $ola, $hd_avatar, $reg_var);
- }
Aide à ce sujet serait grandement apprécié. Merci.
"Bring forth therefore fruits meet for repentance:" Matthew 3:8
- Anonymous
- Bot


- Inscription: 25 Feb 2008
- Messages: ?
- Loc: Ozzuland
- Status: Online
Mai 15th, 2009, 11:02 pm
- Bogey
- Bogey


- Inscription: Juil 14, 2005
- Messages: 8211
- Loc: USA
- Status: Offline
Nevermind, le texte suivant a finalement fait l'affaire. About time I tried that freaking 
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
Code: [ Select ]
if(!empty($_FILES['hd_avatar']['name']))
{
$return[] = $this->update_avatar($_SESSION['user'], $ola, $hd_avatar, $reg_var);
}
{
$return[] = $this->update_avatar($_SESSION['user'], $ola, $hd_avatar, $reg_var);
}
- if(!empty($_FILES['hd_avatar']['name']))
- {
- $return[] = $this->update_avatar($_SESSION['user'], $ola, $hd_avatar, $reg_var);
- }
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
"Bring forth therefore fruits meet for repentance:" Matthew 3:8
- Bogey
- Bogey


- Inscription: Juil 14, 2005
- Messages: 8211
- Loc: USA
- Status: Offline
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!";
}
$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!";
}
- $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!";
- }
"Bring forth therefore fruits meet for repentance:" Matthew 3:8
- joebert
- Sledgehammer


- Inscription: Fév 10, 2004
- Messages: 13455
- Loc: Florida
- Status: Offline
- Bogey
- Bogey


- Inscription: Juil 14, 2005
- Messages: 8211
- Loc: USA
- Status: Offline
- SpooF
- ٩๏̯͡๏۶


- Inscription: Mai 22, 2004
- Messages: 3415
- Loc: Richland, WA
- Status: Offline
- Bogey
- Bogey


- Inscription: Juil 14, 2005
- Messages: 8211
- Loc: USA
- Status: Offline
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
- ٩๏̯͡๏۶


- Inscription: Mai 22, 2004
- Messages: 3415
- Loc: Richland, WA
- Status: Offline
«wget» est un programme en ligne de commande qui retreives fichiers d'un serveur Web.
Usage:
Vous seriez probablement faire quelque chose comme.
pas sûr à 100% si cela va fonctionner.
Vous pourriez également être en mesure d'utiliser http://us3.php.net/curl
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


- Inscription: Juil 14, 2005
- Messages: 8211
- Loc: USA
- Status: Offline
SpooF a écrit:
«wget» est un programme en ligne de commande qui retreives fichiers d'un serveur Web.
Usage:
Vous seriez probablement faire quelque chose comme.
pas sûr à 100% si cela va fonctionner.
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
- ٩๏̯͡๏۶


- Inscription: Mai 22, 2004
- Messages: 3415
- Loc: Richland, WA
- Status: Offline
- Bogey
- Bogey


- Inscription: Juil 14, 2005
- Messages: 8211
- Loc: USA
- Status: Offline
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
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
Page 1 sur 1
Pour répondre à ce sujet, vous devez vous connecter ou vous enregistrer. Il est gratuit.
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
