我上傳圖片的時候有.php,現在當我想上傳圖片時,multipart/form-data .php只是重新加載而沒有更新圖片。 這是的var_dump輸出($ _ FILES)
array(1)
{ ["slika"]=> array(5) {
["name"]=> string(8) "test.png"
["type"]=> string(9) "image/png"
["tmp_name"]=> string(14) "/tmp/phpe46Qae"
["error"]=> int(0)
["size"]=> int(22970) } }
沒有顯示任何錯誤,但圖像沒有上傳。 編輯
This is hole php
form method="POST" action="" name="form" id="form" enctype="multipart/form-data">
<label>Add your photo to the gallery</label><br>
<textarea name="opiss" placeholder="Description" style="margin: 2px; height: 150px; width: 238px;"></textarea><br>
<input name="slika" id="slika" type="file" style="width: 238px;" /><br>
<input type="checkbox" id="frienduh" name="frienduh" value="1"/> Check it.<br>
<span style='color: white;
padding-top: 6px;
font-size: 10px;
float: left;'>
By clicking this your photo will become public!
</span><br><br>
<input type="submit" id="lodd" value="Add" class="button" name="dodaj" />
</form>
<?php
if (isset($_REQUEST['dodaj'])) {
$opis=mysqli_real_escape_string($conn,$_REQUEST['opiss']);
function died($error) {
$poruka = "We are sorry, but there was a problem with upload.\n\nErrors:\n$error\nPlease correct the error and try again.";
?>
<script> alert(<?php echo json_encode($poruka); ?>); setTimeout(function() {window.history.go(-1)}, 500); </script>;
<?php
die();
}
if($_FILES['slika']['size'] < 10485760){
$opis = mysqli_real_escape_string($conn, $_POST['opiss']);
if(strlen($opis)>301){
died('You can enter up to 30 characters in the description field.');
}
$validExtensions = array('.jpg','.JPG','.jpeg','.JPEG','.png','.PNG','.gif','.GIF');
$fileExtension = strrchr($_FILES['slika']['name'], '.');
if (in_array($fileExtension, $validExtensions)) {
$newNamePrefix = time() . '_';
$manipulator = new ImageManipulator($_FILES['slika']['tmp_name']);
// resizing to 200x200
$newImage3 = $manipulator->resample(800, 600);
// saving file to uploads folder
$manipulator->save('galerija/'.$newNamePrefix.$_FILES['slika']['name']);
if (isset($_POST['frienduh'])){
$frienduh=1;
}else{
$frienduh=0;
}
$upis=mysqli_query($conn,"INSERT INTO galerija VALUES(null,".$_SESSION['group_id'].",'".$opis."','".$newNamePrefix.$_FILES["slika"]["name"]."',0,".$frienduh.",0,0)") or die(mysqli_error($conn));
if (isset($_POST['frienduh'])){
$gal=mysqli_query($conn,"SELECT id_gal from galerija where putanja_slike='".$newNamePrefix.$_FILES["slika"]["name"]."'");
$gal_id=mysqli_fetch_array($gal,MYSQL_ASSOC);
$upis2=mysqli_query($conn,"INSERT INTO main_board (id_gal,group_id,doing,content) values(".$gal_id['id_gal'].", ".$_SESSION['group_id'].", 'want to check', '<br><a href=\'/friendornot/photo/".$gal_id['id_gal']."\' title=\'".$opis."\' ><img style=\'max-width:350px;max-height:250px;\' src=\'/galerija/".$newNamePrefix.$_FILES["slika"]["name"]."\'/></a>')") or die(mysqli_error($conn));
}
}else{
died('File type not allowed!');
}
}else{
died('File size must be less than 5MB.');
}
}
只停留大約一兩個星期的工作。這不是我以前的開發人員離開它的代碼。我無法回答爲什麼上傳停止工作。
編輯
是不是跟.PHP問題啓動問題更新的Debian 7和PHP之後。這個.php在localhost和其他服務器上工作。我沒有罰款的解決方案,如果我發現它,我會發布。此外文件夾galerija有所有permision,並在php.ini evrithing是好的
memory_limit = 128M
post_max_size = 12M
file_uploads = On
upload_max_filesize = 12M
你試過上傳的文件 – 2014-11-02 21:35:38
我想弄明白爲什麼這個工作不行,而且以前工作過。我想上傳image- – NKD 2014-11-02 21:57:58
嘗試替換'$ manipulator-> save('galerija /'.$ newNamePrefix。$ _ FILES ['slika'] ['name']);'用'try {$ manipulator-> save('galerija /'.$ newNamePrefix。$ _ FILES ['slika'] ['name']);} catch(Exception $ ex){echo「exception found」; die()}'檢查是否打印異常 – 2014-11-02 22:46:51