Click here to Skip to main content
15,891,657 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Friends I'm Having A Problem If You Help Me It Would Be A Great Way

The Error I Get

>Notice: Undefined index: image in C:\xampp74\htdocs\order\includes\post\ikpost2.php on line 18

>Notice: Trying to access array offset on value of type null in C:\xampp74\htdocs\order\includes\post\ikpost2.php on line 18

where it says line 18 `if php($_FILES['image']["size"] > 0) {`

my codes

<pre lang="PHP">  <pre>  <?php
ob_start();
session_start();
include "../config/config.php";
date_default_timezone_set( 'Europe/Istanbul' );
$settings=$db->prepare("SELECT * from ayarlar where id='1'");
$settings->execute(array(0));
$ayar=$settings->fetch(PDO::FETCH_ASSOC);
$siteurl = $ayar['site_url'];
$site_adi = $ayar['site_baslik'];

?>
<?php 
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
 if (isset($_POST['ikgonder2'])) {


        if ($_FILES['gorsel']["size"] > 0) {


            $dosyas = $_FILES["gorsel"];
            $kaynak = $_FILES["gorsel"]["tmp_name"];
            $dosya = $_FILES["gorsel"]["name"];
            $uzanti = explode(".", $_FILES[gorsel][name]);
            $random = rand(0,(int) 9999999999999);
            $random2 = rand(0,(int) 999);
            $yeni_isim = $random . "-" . $random2 . "-" . $dosya;
            $hedef = "../../../../images/projects/" . $yeni_isim;


            if ($dosyas['type'] == 'image/jpg' || $dosyas['type'] == 'image/jpeg' || $dosyas['type'] == 'image/png') {

                $gitti = move_uploaded_file($kaynak, $hedef);


                $kaydet=$db->prepare("INSERT INTO insan_kaynaklari2 SET
        ad=:ad,
        soyad=:soyad,
        dogumyer=:dogumyer,
        dogumtarih=:dogumtarih,
        uyruk=:uyruk,
        cinsiyet=:cinsiyet,
        ikametgah=:ikametgah,
        telefonno=:telefonno,
        eposta=:eposta,
        askerlik=:askerlik,
        surucubelge=:surucubelge,
        kangrubu=:kangrubu,
        medenidurum=:medenidurum,
        sigaradurum=:sigaradurum,
        egitimdurum=:egitimdurum,
        yabancidildurum=:yabancidildurum,
        tecrube=:tecrube,
        saglikprob=:saglikprob,
        mahkum=:mahkum,
        referans=:referans,
        ucret=:ucret,
        gorsel=:gorsel,
        vardiya=:vardiya,
        durum=:durum,
        tarih=:tarih
        ");
                 $ekle=$kaydet->execute(array(
            'ad' => trim(strip_tags($_POST['ad'])),
            'soyad' => trim(strip_tags($_POST['soyad'])),
            'dogumyer' => trim(strip_tags($_POST['dogumyer'])),
            'dogumtarih' => trim(strip_tags($_POST['dogumtarih'])),
            'uyruk' => trim(strip_tags($_POST['uyruk'])),
            'cinsiyet' => trim(strip_tags($_POST['cinsiyet'])),
            'ikametgah' => trim(strip_tags($_POST['ikametgah'])),
            'telefonno' => trim(strip_tags($_POST['telefonno'])),
            'eposta' => trim(strip_tags($_POST['eposta'])),
            'askerlik' => trim(strip_tags($_POST['askerlik'])),
            'surucubelge' => trim(strip_tags($_POST['surucubelge'])),
            'medenidurum' => trim(strip_tags($_POST['medenidurum'])),
            'kangrubu' => trim(strip_tags($_POST['kangrubu'])),
            'sigaradurum' => trim(strip_tags($_POST['sigaradurum'])),
            'egitimdurum' => trim(strip_tags($_POST['egitimdurum'])),
            'yabancidildurum' => trim(strip_tags($_POST['yabancidildurum'])),
            'tecrube' => trim(strip_tags($_POST['tecrube'])),
            'saglikprob' => trim(strip_tags($_POST['saglikprob'])),
            'mahkum' => trim(strip_tags($_POST['mahkum'])),
            'referans' => trim(strip_tags($_POST['referans'])),
            'ucret' => trim(strip_tags($_POST['ucret'])),
            'vardiya' => trim(strip_tags($_POST['vardiya'])),
 'gorsel' => $yeni_isim,
            'durum' => 1,

            'tarih' => $timestamp

        ));
                if ($ekle) {

                     header("location: ".$siteurl."insan-kaynaklari?status=success");

                } else {

                    Header("location: ".$siteurl."insan-kaynaklari?status=warning");

                }

            } else {
                Header("location: ".$siteurl."insan-kaynaklari?status=imgtype");
            }

        }


    }



?>


What I have tried:

guys i need help so much i am waiting for your help
Posted
Updated 5-Nov-22 23:04pm
v2
Comments
Member 15627495 13-Aug-22 23:22pm    
it seems to be a syntax error, you use both '' and " "
stay with '' or "" to access your array

No Bro
the problem is here
if ($_FILES['gorsel']["size"] > 0) {
 
Share this answer
 
Comments
Richard MacCutchan 14-Aug-22 11:04am    
The message is telling you that $_FILES does not contain an element at the addressed offset. Use your debugger to find out why.
$uzanti = explode(".", $_FILES[gorsel][name]);

It seems gorsel and name are supposed to be in quotes, maybe?
 
Share this answer
 
Comments
İsmet Özdeş 14-Aug-22 4:36am    
the problem is here
if ($_FILES['gorsel']["size"] > 0) {

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900