joliocesar Posted September 30, 2008 Share Posted September 30, 2008 hi , i have a upload form in a form that have 3 other fields ... but upload variable doesn't work Truly and don't have anything ! why ? in can't use file form in a form has other fields !!! can anybody help me ! i really need it fast .. my project is not work without it ... thanks afshin Link to comment https://forums.phpfreaks.com/topic/126461-upload-form/ Share on other sites More sharing options...
trq Posted September 30, 2008 Share Posted September 30, 2008 We can't help you without seeing the relevent code. Link to comment https://forums.phpfreaks.com/topic/126461-upload-form/#findComment-653887 Share on other sites More sharing options...
joliocesar Posted September 30, 2008 Author Share Posted September 30, 2008 if($mode=="link_select") { $cat = htmlspecialchars($_POST['cat_1']); $query = "select * from link where cat='$cat'"; $query = mysql_query($query); ?> <div style="float:left;margin-left:15px;"> <form method="post" action="?mode=add" enctype='multipart/form-data'> <input type="hidden" name = "form_qq" value="1"> <table > <tr><td bgcolor="#FFF8CC">link Title</td><td><input type="text" name="title"></td></tr> <tr><td bgcolor="#FFF8CC">Link description</td><td><textarea name="pre" id="pre" rows="10" cols="30"></textarea></td> <tr><td bgcolor="#FFF8CC">Address</td><td><input type="text" name="address"></td></tr> <tr><td bgcolor="#FFF8CC">Price <?echo $price_se?></td><td><input type="text" name="price"></td></tr> [color=green][b]This is my photo form :[/b][/color] <tr><td bgcolor="#FFF8CC">Photo</td><td><input type="file" name="photo"></td></tr> </tr> <tr> <td bgcolor="#FFF8CC">Sub Link</td><td > <input type="hidden" name="categor" value="<?echo $cat;?>"/> <select name="sub_link"> <option>New Link</option> <? while ($query2 = mysql_fetch_array($query)) { $id = $query2['id']; if($query2['menu_id']=="0") { echo "<option>$query2[title]</option>"; $selects = "select * from sub_link where cat='$cat' and menu_id='$id'"; $selects=mysql_query($selects); while($query3 = mysql_fetch_array($selects)) { echo "<option style=\"color:red;background-color:yellow;\">$query3[title]</option>"; ?> <? $id2 = $query3['id']; $queryssg = "select * from sublink_2 where cat='$cat' and menu_id='$id2'"; $queryssg = mysql_query($queryssg); while($query3g = mysql_fetch_array($queryssg)) { echo "<option style=\"color:red;background-color:#B0F9FD;\">$query3g[title]</option>"; } } } } ?> </select> <tr><td bgcolor="#FFF8CC"><input type="submit" value="Add Link" name="add"></td> <td bgcolor="#FFF8CC"> </td></tr> </table> </form></div> <? } this is code of form if($mode=="add") { if($form_qq == "1") { $title = htmlspecialchars($_POST['title']); $pre = $_POST['pre']; $address = htmlspecialchars($_POST['address']); $sub_link = htmlspecialchars($_POST['sub_link']); $cat_1 = htmlspecialchars($_POST['categor']); $price = htmlspecialchars($_POST['price']); $photo = $_FILES['photo']['tmp_name']; $file_name = $_FILES['photo']['name']; $file_size = $_FILES['photo']['size']; $file_type = $_FILES['photo']['type']; $file_error= $_FILES['photo']['error']; $file_title= basename($file_name); $filetypex = substr($file_type,0,5); $date = time(); if(strlen($address) <= "0") { $select = "select * from link order by id desc limit 1"; $select = mysql_query($select); if($select_add = mysql_fetch_array($select)) { $addressid = $select_add['id']; $addressid = $addressid + 1; } $address = "../shop/shop.php?mode=cart&sublink=0&id=$addressid"; } $selectg = "select * from link order by rdf asc limit 1"; $selectg = mysql_query($selectg); if($select_2 = mysql_fetch_array($selectg)) { $last = $select_2; } if($filetypex == "image") { move_uploaded_file($_FILES['file']['tmp_name'],"photo.img"); $update = fopen("photo.img","rb"); $image = addslashes(fread($update,filesize("photo.img"))); $size = getimagesize("photo.img"); $width = $size['0']; $height = $size['1']; if($width <= "300" or $height <= "300") { $query = "insert into link(title,pre,date,cat,sublink,l_address,menu_id,username,rdf,price,link_photo) values ('$title','$pre','$date','$cat_1','$sub_link','$address','0','$username_2','1+$last','$price,'$photo')"; } else { error("Photo size must be under 300px with * 300px height Size"); exit; } } else if(empty($photo)){ $query = "insert into link(title,pre,date,cat,sublink,l_address,menu_id,username,rdf,price) values ('$title','$pre','$date','$cat_1','$sub_link','$address','0','$username_2','1+$last','$price')"; } if(mysql_query($query)) { noerror("link added successfully"); } and this is add process Link to comment https://forums.phpfreaks.com/topic/126461-upload-form/#findComment-653905 Share on other sites More sharing options...
trq Posted September 30, 2008 Share Posted September 30, 2008 Are you getting any errors or anything? Can you try and be at least a little descriptive, were not mind readers. Link to comment https://forums.phpfreaks.com/topic/126461-upload-form/#findComment-653930 Share on other sites More sharing options...
PFMaBiSmAd Posted September 30, 2008 Share Posted September 30, 2008 Add the following to your form processing code - echo "<pre>"; echo "POST:"; print_r($_POST); echo "FILES:"; print_r($_FILES); echo "</pre>"; Link to comment https://forums.phpfreaks.com/topic/126461-upload-form/#findComment-653943 Share on other sites More sharing options...
joliocesar Posted September 30, 2008 Author Share Posted September 30, 2008 Are you getting any errors or anything? Can you try and be at least a little descriptive, were not mind readers. hi , i don't get any errors ! i don't know how i can descript it ! i have a form that must upload a image and send title and preview and price and address to database ... all of that fields send contents by post method and any of that sending but <input type='file' name='photo'> don't send any thing to process part ... is possible my form code was not correct ? thank you so much ... Link to comment https://forums.phpfreaks.com/topic/126461-upload-form/#findComment-653978 Share on other sites More sharing options...
joliocesar Posted September 30, 2008 Author Share Posted September 30, 2008 Add the following to your form processing code - echo "<pre>"; echo "POST:"; print_r($_POST); echo "FILES:"; print_r($_FILES); echo "</pre>"; hey , Array ( [form_qq] => 1 [title] => as dasd as [pre] => dsa das dasd [address] => [price] => 12 [photo] => 2ykmlmo.jpg [categor] => a [sub_link] => New Link [add] => Add Link ) printed for $_POST and \ array() printed for $_FILES Link to comment https://forums.phpfreaks.com/topic/126461-upload-form/#findComment-654044 Share on other sites More sharing options...
PFMaBiSmAd Posted September 30, 2008 Share Posted September 30, 2008 Your posted form functions and uploads a file. So, an empty $_FILES array would mean uploads are not enabled on your server or your code has overwritten the $_FILES array. Link to comment https://forums.phpfreaks.com/topic/126461-upload-form/#findComment-654071 Share on other sites More sharing options...
joliocesar Posted September 30, 2008 Author Share Posted September 30, 2008 i cant find any more in my code ! i have the same form that has only file type input .. and that is working good .. but on this form i don't know ! i'm confused ... ??? can you help me and show me the correct form code that's working truly ? thank you so much Link to comment https://forums.phpfreaks.com/topic/126461-upload-form/#findComment-654088 Share on other sites More sharing options...
PFMaBiSmAd Posted September 30, 2008 Share Posted September 30, 2008 You could also have nested/invalid forms and the form tag you posted is not having any effect in the browser. You would need to post all the code in the relevant file(s) to get any specific help with what it is doing (assuming uploads are enabled on your server to begin with.) Link to comment https://forums.phpfreaks.com/topic/126461-upload-form/#findComment-654304 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.