Jump to content
php.lv forumi

Kāpēc es nevaru augsuplādēt failus?


Matainais

Recommended Posts

Esmu tikko sācis darboties šajā tēmā, tāpēc neesiet bargi.

Man ir lapa, kurā ielogojoties jāvar mainīt takstus un bildes. taksti iet, bet bildes ne. man pat error neizmat, vienkārši nelādē.

varbūt es no sākuma juau visu izdariju nepareizi?

 

<a  href="javascript:change_photo('.$row['ID'].',2);" ><img class ="bilde_d_e" src="images/picture.png" title="Mainīt bildi" /></a>

kas aizved uz javaskripta failu, kurā rakstīju(x ir tāpēc, ka man jāmaina bildes vairākās sadaļās)

 

function change_photo(id,x)
{
//alert(id+'vertiba');
if (x == 1) mape = 'photo';     // photo kontaktu
else if(x==2) mape = 'pakalp';   //uznemuma pakalpojumu bildes
else if(x==3) mape = 'apraksts';   //uznemuma apraksta bilde
else if(x==4) mape = 'sadala';   //vel kadas sadalas bilde
else alert(id+' '+y);

 var generator=window.open('','name','height=200,width=400,toolbar=no');
   generator.document.write('<html>');
generator.document.write('<body><form action="upload_photo.php" method="post"');
generator.document.write('enctype="multipart/form-data">');
generator.document.write('<label for="file">Faila nosaukums:</label>');
generator.document.write('<input type="file" name="file" id="file" /> ');
generator.document.write('<br />');
generator.document.write('<input id="bilde" name="bilde" type="hidden" value="'+ id +'"/>');
generator.document.write('<input id="mape" name="mape" type="hidden" value="'+ mape +'"/>');
generator.document.write('<input type="submit" name="submit" value="Labi" />');
generator.document.write('</form></body>');
generator.document.write('</html>');
   generator.document.close();

}

 

un tad man ir upload fails

 

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="lv" lang="lv">
<head>
<title>file upload</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="style.css" type="text/css" />
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript" src="java.js"></script>
<script type="text/javascript" src="pamata_javascript.js"></script>
<script type="text/javascript">
google.load("jquery", "1");
</script>

<!-- Load TinyMCE -->
<script type="text/javascript" src="../jscripts/tiny_mce/jquery.tinymce.js"></script>
</head>
<body>
<p id="mazais_logs"><?php
//print_r($_POST);

if($_POST["action"] == "Upload Image")

if(!isset($_POST["bilde"])) echo "neatsūtījās!";
if ((($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/jpg")
|| ($_FILES["file"]["type"] == "image/pjpeg"))
&& ($_FILES["file"]["size"] < 300000))
 {
 if ($_FILES["file"]["error"] > 0)
   {
   echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
   }
 else
   {
   echo "Upload: " . $_FILES["file"]["name"] . "<br />";
   echo "Type: " . $_FILES["file"]["type"] . "<br />";
   echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
   echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";    if (file_exists($_POST['mape']."/" . $_FILES["file"]["name"]))
     {
     echo $_FILES["file"]["name"] . " already exists. ";
     }
   else
     {
     move_uploaded_file($_FILES["file"]["tmp_name"],$_POST['mape']."/" . $_POST["bilde"]);
     echo "Stored in: " . $_POST['mape']. "/" . $_POST["bilde"];
  echo "<script language=javascript>beigt()</script>";
     }
   }
 }
else
 {
 echo "Nepareizs fails";
 }  


?>
</p>
</body>
</html>

 

 

 

Lieta tāda, ka upload logs parādās, es varu norādīt failu un nospiest submit, taču tas fails nekur neparādās, ne lapā, ne uz servera, es laikam nepareizi saglabāju.

 

jebkurā gadījumā būšu pateicīgs par paomiem, jo no php es neko nejēdzu.

Edited by Matainais
Link to comment
Share on other sites

Pilnīgi nekas nerādās? O.o

 

Pamēģini ielikt failā (kas beidzas ar .php) šo te...

 

<?php

 echo 'Hello, world!';

 

 

izdarīju un rezultāts bija gaidītais: teksta rindiņa hello world.

php man strādā, man drīzāk liekas, ka es to upload failu esmu nepareizi uzrakstījis, tikai es nesaprotu, kur. Iespējams es, esmu kaut ko kodā izlaidis.

Link to comment
Share on other sites

Ja kas nav labi, tad vajadzētu parādīties kļūdai.

 

Ieslēdz kļūdu paziņojumus (pirms visa pārējā koda)...

 

error_reporting( E_ALL | E_STRICT );

 

Ja tomēr nekas nerādās, tad, iespējams... Failā php.ini šo te - display_error - padari pozitīvu. =]

Link to comment
Share on other sites

action="upload_photo.php"

 

Šī te daļa aizsūta datus uz "upload_photo.php" failu, vai tajā atrodas tie dati vai nē? Tu taču ielādē savus JS iekš, tā faila kur tev ir pārējais. Manuprāt nomaini to uz:

 

action=""

 

Un pamēģini šādi ;)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...