PHP/HTML question.
#1

Ok, i really need help here;

Because on the dutch board i don't get help :-/ (screw you guys).

This is a part of my php file:
PHP код:
$picfilename $_FILES['pic_map']['tmp_name'];
            
            echo 
'<b>Name: '.$picfilename;
            
$picsize getimagesize($picfilename);
            
            echo 
$picsize
This is my form:

Код HTML:
<form name="addmapform" method="post" action="objectadd.php">
								&nbsp;&nbsp;Account name: <input type="text" name="name" id="name"><br>
								&nbsp;&nbsp;Account password: <input type="password" name="pass" id="pass"><p></p>
								<label for="ref">&nbsp;&nbsp;<big>Map Name:</big></label><br>
								&nbsp;&nbsp;<input name="ref" type="text" id="ref" value="" size="50"><p></p>
								&nbsp;&nbsp;Type<br>
								<select name="objecttype" id="objecttype">
									<option value="PAWN_Code">PAWN code</option>
									<option value=".map">.map file</option>
								</select><p></p>
								<label for="pawn_objects"><b><big>&nbsp;&nbsp;Map data:</b></big></label>
								<p>
									<i>Objects</i><br>
									<textarea name="pawn_objects" id="pawn_objects" cols="50" rows="10">Here CreateObject();</textarea><br>
									<i>Cars</i><br>
									<textarea name="car_spawns" id="car_spawns" cols="50" rows="30">Here CreateVehicle();</textarea>
									<!--<label for="datafile">or upload .map file:<br></label>
									<input type="file" id="datafile" name="datafile" size="40">-->
								</p>
<label for="pic_map"><b><big>&nbsp;&nbsp;Map screenshot (size must be 125x125)</big></b><br>
&nbsp;&nbsp;<input type="file" id="pic_map" name="pic_map" size="40"><p></p>
&nbsp;&nbsp;<input type="submit" name="submit" id="submit" value="Submit my map !">
							</form>
The problem is that i don't get something... it doesn't show the echo's. I want to check the image size, then it should be save somewhere + showing on a webpage. So like image uploading...
Reply
#2

So basically it's not reaching a piece of code? You might want to include the surroundings of that.
Reply
#3

i think you have do to like echo $_GET['picfilename'];
Reply
#4

Add enctype="multipart/form-data" to your <form>.

I want to check the image size, then it should be save.

PHP код:
list($width$height$type$attr) = getimagesize($_FILES['pic_name']['tmp_name']);
if (
$width 125 || $height 125)
{
  echo 
"Maximum width and height exceeded. Please upload images below 125 x 125 px size";
  exit();
}
// Check file extension then save the file. 
Quote:
Originally Posted by mevi
Посмотреть сообщение
i think you have do to like echo $_GET['picfilename'];
Are you blind :P ? He is clearly using POST method.
Reply
#5

Quote:
Originally Posted by XFlawless
Посмотреть сообщение
Add enctype="multipart/form-data" to your <form>.

I want to check the image size, then it should be save.

PHP код:
list($width$height$type$attr) = getimagesize($_FILES['pic_name']['tmp_name']);
if (
$width 125 || $height 125)
{
  echo 
"Maximum width and height exceeded. Please upload images below 125 x 125 px size";
  exit();
}
// Check file extension then save the file. 

Are you blind :P ? He is clearly using POST method.
Ok i did this:

Код HTML:
<form name="addmapform" method="post" action="objectadd.php" enctype="multipart/form-data">
And what does "exit();" do ?

EDIT

PHP код:
echo $width " - " $height " - " $type " - " $attr
tried this, but doesnt show something
Reply
#6

Quote:
Originally Posted by Michael@Belgium
Посмотреть сообщение
And what does "exit();" do ?
exit(); and die(); do the same work they'll kill the process.
Reply
#7

Quote:
Originally Posted by royal_king
Посмотреть сообщение
exit(); and die(); do the same work they'll kill the process.
Oh ok; btw i've fixed the 'getsize' issue. But now the file don't get moved to another directory :S

I've this:
PHP код:
$upload_dir '/MapImages';
                    
$tmp_name $_FILES['pic_map']['tmp_name'];
                    
$name $_FILES['pic_map']['name'];
                    
move_uploaded_file($tmp_name,"$upload_dir/$name"); 
                    echo 
"Image "$_FILES['pic_map']['name'] ." uploaded successfully.<br>"
and also tried:

PHP код:
move_uploaded_file($_FILES['pic_map']['tmp_name'],"/httpdocs/MapImages/".$_FILES['pic_map']['name']); 
both don't work
Reply
#8

PHP код:
$filename $_FILES["pic_map"]["name"]; 
$filetmplocation $_FILES["pic_map"]["tmp_name"];
$path "MapImages/".$filename;
$result move_uploaded_file($filetmllocation$path);
if (
$result == true) {
    echo 
"File has been moved from " $filetmplocation " to" $path;
} else {
     echo 
"ERROR: File not moved correctly";

Try to debug each output.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)