Jump to content
php.lv forumi

avatar upload script


ezis

Recommended Posts

cenšos uztaisīt skriptu, kas ļauj uploadot attēlus kurus pēcāk izmantos lietotājiem avatarā..

bet problēma ir tāda, ka nostrādā errors par nepareizu faila formātu, bet tā nav.1 :@ nezinu kur ir vaina..

varbūt nepareizi ko esmu saraxtījis :\

pati forma:

<form class="form" method="post" action="<?=$_SERVER['REQUEST_URI']?>">

<input type="hidden" name="_submit_check_avatarup" value="1"/> 
 <label for="imagefile">izvēlies attēlu:</label>
 <input type="file" name="imagefile" id="imagefile" class="form">
 <br /><br />
 <input type="reset" value="Clear" class="form">
 <input type="image" name="register" value="register"  class="submit-btn_up" src="template_images/boxes/btn.gif" alt="submit" title="submit" />
 </form>

 

un php:

$idir = "images/";


if ( array_key_exists ( '_submit_check_avatarup', $_POST ) )
{

 if ((($_FILES['imagefile']['type'] == "image/jpg") || ($_FILES['imagefile']['type'] == "image/jpeg") || ($_FILES['imagefile']['type'] == "image/gif")) && ($_FILES["imagefile"]["size"] < 9000000)) {
$copy = copy($_FILES['imagefile']['tmp_name'], "$idir" . $_FILES['imagefile']['name']); 



if ($copy) {

  $msg_av = 'Tavs avatars ir ielādēts.';
} else {
  $error_av = 'Neizdevās ielādēt avataru.';
}
 } else {
  $error_av = 'Nepareizs faila formāts.';
 } 
 }

Edited by ezis
Link to comment
Share on other sites

Viss jau it kā pareizi, tikai <form> tagā aizmirsi norādīt tādu lietu, kā "enctype":

<form class="form" method="post" enctype="multipart/form-data" action="<?=$_SERVER['REQUEST_URI']?>">

jup ^^ tas palīdzēja paldies :)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...