ho creato questo codice per far caricare foto a utenti:
Codice PHP:
$userinfo = mysql_fetch_array(mysql_query("SELECT name, sex FROM ibwf_users WHERE id='".$uid."'"));
$membername = $userinfo[0];
// we have three forms on the test page, so we redirect accordingly
if ($_POST['action'] == 'image') {
echo "<p align=\"center\">";
// ---------- IMAGE UPLOAD ----------
// we create an instance of the class, giving as argument the PHP object
// corresponding to the file field from the form
// All the uploads are accessible from the PHP object $_FILES
$handle = new Upload($_FILES['my_field']);
// then we check if the file has been uploaded properly
// in its *temporary* location in the server (often, it is /tmp)
if ($handle->uploaded) {
// yes, the file is on the server
// below are some example settings which can be used if the uploaded file is an image.
$handle->image_resize = true;
$handle->image_ratio_y = true;
$handle->image_x = 150;
// now, we start the upload 'process'. That is, to copy the uploaded file
// from its temporary location to the wanted location
// It could be something like $handle->Process('/home/www/my_uploads/');
$handle->Process('usergallery/');
// we check if everything went OK
if ($handle->processed) {
// everything was fine !
echo ' file uploaded with success
';
echo ' [img]usergallery/' . $handle->file_dst_name . '[/img]
';
$info = getimagesize($handle->file_dst_pathname);
echo ' link to the file just uploaded: [url="../usergallery/' . $handle->file_dst_name . '"]' . $handle->file_dst_name . '[/url]
';
$imageurl = "http://sito.it/wap/usergallery/$handle->file_dst_name";
$reg = mysql_query("INSERT INTO ibwf_gallery SET uid='".$uid."', imageurl='".$imageurl."', sex='".$userinfo[1]."', time='".(time() - $timeadjust)."'");
} else {
// one error occured
echo ' file not uploaded to the wanted location
';
echo ' Error: ' . $handle->error . '
';
}
// we delete the temporary files
$handle-> Clean();
} else {
// if we're here, the upload file failed for some reasons
// i.e. the server didn't receive the file
echo ' file not uploaded on the server
';
echo ' Error: ' . $handle->error . '';
}
con questa funzione ogni utente carica nella 'propria gallery delle foto...
vorrei però che un admin possa caricare immagini direttamente nelle gallery degli utenti...
mi potete aiutare?
grazie :master: