Note that there are some explanatory texts on larger screens.

plurals
  1. POHandle tmp file in form upload and pass the file to other form before uploaded
    primarykey
    data
    text
    <p>I need help badly , can't fix it to working like i want..!</p> <p>I have two forms , one is contact form , and the other is image upload inside the contact form,the forms using AJAX for proccsesing.</p> <p><img src="https://i.stack.imgur.com/0YOyY.jpg" alt="my form example"></p> <p>I <strong>dont</strong> want to move_upload_file unless the all form(contact)is submited. so so far its all working, <strong>exept</strong> when i try to pass the file over the contact form and use<code>@move_upload_file</code> it wont move the file to the server.</p> <p>I using this way to transfer the file and when i am doing var_dump its working perfect :</p> <pre><code> if ($proc == "question") { // Handle some normal form 'contact us'. // ... Some proccses code when submited via ajax ... $fileElementName = 'ImageBrowse'; //This session coming from other proccses form down if isset. if(isset($_SESSION['imgfilename']) &amp;&amp; !empty($_SESSION['imgfilename'])){ //Then i handle it with list to make the rest of the proccses. list($uploadFilename,$_FILES['ImageBrowse']) = $_SESSION['imgfilename']; //unset session for security. unset($_SESSION['imgfilename']); } var_dump($_FILES['ImageBrowse']); // will print the file array perfect. //Trying now to move_uploaded_File if(@move_uploaded_file($_FILES['ImageBrowse']['tmp_name'],$uploadsDirectory.$uploadFilename)){ echo 'Uploaded!'; }else{ echo 'Not Uploaded'; } // and here is the problem , it wont move uploaded file , even if there is array of the file.. } else if ($proc == "sendQuestionUploadImg") { // Handle img upload via ajax. $fileElementName = 'ImageBrowse'; $uploadsDirectory = '../uploads/'; $allowedTypes = array ( 'image/jpeg', 'image/jpg', 'image/pjpeg', 'image/pjpeg', 'image/png', 'application/x-rar-compressed' ); // ... Some more proccses code when submited via ajax ... // In the end if goes well... // I want to pass the file array to the other if above. if (isset($msg) &amp;&amp; !empty($msg)) { // I insert the file array into session for take the rest of the proccses in above form if. $_SESSION['imgfilename'] = array($uploadFilename,$_FILES['ImageBrowse']); //If i use here , it will work. if(@move_uploaded_file($_FILES['ImageBrowse']['tmp_name'],$uploadsDirectory.$uploadFilename)){ echo 'Uploaded!'; }else{ echo 'Not Uploaded'; } // } else { @unlink($_FILES[$fileElementName]); } </code></pre> <p>As you see i pass the whole file array into session, and call it above in the other if proccses for more proccses, when i using <code>@move_upload_file</code> inside the <code>$proc == "sendQuestionUploadImg"</code> it will work perfect and will upload the file , but if i try to use <code>@move_upload_file</code> inside the other if it won't any one know why?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload