mirceabondar Posted October 19, 2012 Share Posted October 19, 2012 In tmheaderlink am adaugat un link care contine un formular de comanda orintre care si un upload de fisiere(formularul apare "fade" cand dau pe click. Pentru uploadul de fisier am adaugat un script java care face legatura intre formular si scriptul php care preia fisierul. Problema este ca nu functioneaza, nu imi urca fisierul pe server. Daca pun intrul singur loc forumularul, scriptul php, scriptul java si folderul unde urca fisierele, totul merge perfect. Ca fisiere am asa: In tmheaderlink: <div class="clearblock"></div> <ul id="tmheaderlinks"> <li><a href="{$link->getPageLink('index.php')}"{if $page_name == 'index'} class="active"{/if}><span>{l s='home' mod='tmheaderlinks'}</span></a></li> <li><a href="{$link->getPageLink('prices-drop.php')}"{if $page_name == 'prices-drop'} class="active"{/if}><span>{l s='Reduceri' mod='tmheaderlinks'}</span></a></li> <li><a href="{$link->getPageLink('contact-form.php')}"{if $page_name == 'contact-form'} class="active"{/if}><span>{l s='contact' mod='tmheaderlinks'}</span></a></li> <li><a href="#" id="ajutor"><span>Ajutor</span></a></li> <li><a href="#" id="comanda"><span>Cerere oferta</span></a></li> </ul> <div id="program"></div> <div id="message"></div> <form name="upload" id="upload" action="#" method="POST" enctype="multipart/form-data"> <table cellpadding="4" cellspacing="4" border="0"> <tr> <td colspan="2"><h1>Upload File via Ajax</h1></td> </tr> <tr> <td class="fieldLabel" nowrap>File:</td> <td nowrap><input type="file" name="file" id="file" /></td> </tr> <tr> <td nowrap colspan="2"><input type="submit" id="uploadFile" value="Upload File" /></td> </tr> </table> </form> <div id="uploader"></div> <div id="contact_comanda"> <div id="x"><a id="close" href="javascript:x()"></a></div> <h3 class="h3">Incarca document</h3> <h1 class="h1">Descriere lucrare</h1> <form action="" method="post"> <table> <tr> <td class="td" > <label for="dimensiunex">Dimensiuni L (mm)</label> </td> <td> <input class="dimensiuni" type="text" name="dimensiuneL" onkeydown= size="30"/> <label for="dimensiuni">x l (mm)</label> <input class="dimensiuni" type="text" name="dimensiunel" size="30"/> </td> </tr> <tr> <td class="td"> <label for="hartie">Hartie</label> </td> <td> <input class="input" type="text" name="hartie" size="30" /> </td> <td class="td"> <label for="biguri">Biguri</label> </td> <td> <select class="input" name="biguri"> <option value="da">Da</option> <option value="nu">Nu</option> </select> </td> </tr> <tr> <td class="td"> <label for="gramaj">Gramaj</label> </td> <td> <input class="input" type="text" name="gramaj" size="30" /> </td> <td class="td"> <label for="perfor">Perfor</label> </td> <td class="td"> <select class="input" name="perfor"> <option value="da">Da</option> <option value="nu">Nu</option> </select> </td> </tr> <tr> <td class="td"> <label for="inseriere">Inseriere</label> </td> <td> <input class="input" type="text" name="inseriere" size="30" /> </td> <td class="td"> <label for="tipar">Tipar</label> </td> <td> <select class="input" name="tipar"> <option value="4+0">4 + 0</option> <option value="4+4">4 + 4</option> <option value="1+0">1 + 0</option> <option value="1+1">1 + 1</option> </select> </td> </tr> <tr> <td class="td"> <label for="plastifiere">Plastifiere</label> </td> <td> <select class="input" name="plastifiere"> <option value="fara">Fara plastifiere</option> <option value="coperta lucioasa">Coperta lucioasa</option> <option value="coperta mata">Coperta mata</option> <option value="lucioasa integral">Lucioasa integral</option> <option value="mata integral">Mata integral</option> </select> </td> <td class="td"> <label for="cantitate">Cantitate</label> </td> <td> <input class="input" type="text" name="cantitate" size="30" /> </td> </tr> <tr> <td class="td"> <label for="legare">Legare</label> </td> <td> <select class="input" name="legare"> <option value="spira metal">Spira metal</option> <option value="spira plastic">Spira plastic</option> <option value="capsare">Capsare</option> <option value="brosare">Brosare</option> <option value="scoarta">Scoarta</option> </select> </td> <td class="td"> <label for="numarpag">Numar pagini</label> </td> <td> <input class="input" type="text" name="numarpag" size="30" /> </td> </tr> <tr> <td class="td"> <label for="observatii">Observatii</label> </td> <td colspan="3"> <textarea id="textarea_comanda" name="observatii"></textarea> </td> </tr> <td colspan="5"> <h2 class="h2">Date de contact</h2> </td> <tr> <td class="td"> <label for="compania">Compania</label> </td> <td> <input class="input" type="text" name="compania" size="30" /> </td> </tr> <tr> <td class="td"> <label for="nume">Nume</label> </td> <td> <input class="input" type="text" name="nume" size="30" /><span class="require">*</span> </td> </tr> <tr> <td class="td"> <label for="email">Email</label> </td> <td> <input class="input" type="text" name="email" size="30" /><span class="require">*</span> </td> </tr> <tr> <td class="td"> <label for="email">Telefon</label> </td> <td> <input class="input" type="text" name="telefon" size="30" /><span class="require">*</span> </td> </tr> <tr> <td></td> <td><input id="trimite" type="submit" name="trimite" value="Trimite cererea" /></td> <td><input id="inchide" type="reset" name="inchide" value="Anuleaza" /></td> </tr> </table> In scriptul java am asa: $(document).ready(function() { var options = { target: '#message', //Div tag where content info will be loaded in url:'upload_file/upload.php', //The php file that handles the file that is uploaded success: function() { //Here code can be included that needs to be performed if Ajax request was successful $('#uploader').html(''); } }; $('#upload').submit(function() { $(this).ajaxSubmit(options); return false; }); }); Si php: <?php error_reporting(0); $target_path = "client_upload/"; /* folderul in care se vor uploada fisierele */ $target_path = $target_path . basename( $_FILES['file']['name']); if(move_uploaded_file($_FILES['file']['tmp_name'], $target_path)){ } else{ echo "Avem probleme la uploadare!"; } ?> Posibil sa javascriptul sa nu parcurga directorul pana la upload.php? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now