How can I upload images

Hi everyone :slight_smile:
How can I add images to a page without the panel?
Can I do it directly when creating the page? So with page()->create() or how do I do it?

   /*File-1*/
   $image = array('name' => $title, 'type' => 'image/jpg', 'bits' => new IXR_Base64($theData), 
   'overwrite' => true, 'post_id' => $post_id );
   curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query(
		array('data_id' => $data_id, 'ID' => $data->ID, 'project' => $project, 'parent' => $data- 
    >parent, 'imgsrcfolder' => $data->imgsrcfolder, 'image' => $image, 'text' => $data->text))
    );
     curl_exec($ch);
     curl_close($ch); 

    /*File-2*/
    $image = get('image');
    $p = page($category)->children()->create($pagenameM, 'default', array(
        'title' => $title,
        'text' => $text,
      ));

Check out this thread: Allow guests to create pages from Panel or frontend