Jump to content

files is not uploaded?


bilis_money

Recommended Posts

hi, i hope there is kind people that can help me here.

The only problem is, after pressing the upload button

and then checking the directory i saw no files, what i mean is there is no file being uploaded into the specified directory, why is this?

 

I know this is working before, i just can't figure it out right now, i'm lost.

 

can someone please guide meh.

 

preupload.php

<?php
session_start();

//remove white spaces and periods.
$string = $_POST['name'];
$replace_what = array(" ", ".");
$replace_with = array("","");
$cut_name = str_replace($replace_what, $replace_with, $string); 

//store directory name into memory.
$_SESSION['tempdir'] = $cut_name;

//make directory folder using $cut_name
mkdir("$cut_name", 0777);
?>

<?php 
if (isset($_POST['Submit'])) {    
$recepient = "[email protected]";
$subject = "You have Guest! from travelsconsult.com/model/";    
$contents = "Full Name:  " . $_POST['name'] .    			
"\n\nAddress:  " . $_POST['address'] .    			
"\n\nAge:  " . $_POST['age'] .    			
"\n\nStatus:  " . $_POST['status'] .    			
"\n\nEtnicity:  " . $_POST['ethnicity'] .    			
"\n\nHeight:  " . $_POST['height'] .    			
"\n\nChest:  " . $_POST['chest'] .				
"\n\nWaist:  " . $_POST['waist'] .    			
"\n\nHips:  " . $_POST['hips'] .    			
"\n\nWeight:  " . $_POST['weight'] .    			
"\n\nHair:  " . $_POST['hair'] .    			
"\n\nEyes:  " . $_POST['eyes'] .    			
"\n\nContact:  " . $_POST['contact'] .    			
"\n\nEmail:  " . $_POST['email'] .    			
"\n\nCountry:  " . $_POST['country'] .    			
"\n\nPrevious job:  " . $_POST['previousjob'] .    			
"\n\nPresent job:  " . $_POST['presentjob'] .    			
"\n\nEducation:  " . $_POST['education'];}    

$headers = "Reply-to: [email protected]\n";    
mail($recepient, $subject, $contents, "From: [email protected]");
?>


<?php
// initialization
$photo_upload_fields = "";
$counter = 1;

// default number of fields
$number_of_fields = 5;

echo "<br><br><center><h3>";
echo "Please Upload your latest photo full and half body.";
echo "</h3></center>";

// Lets build the Photo Uploading fields
while($counter <= $number_of_fields)
{
$photo_upload_fields .=<<<__HTML_END
<tr>
<td>
     Photo {$counter}:
    <input name='photo_filename[]' type='file' />
</td>
</tr>
__HTML_END;
$counter++;
}

// Final Output
echo <<<__HTML_END
<html>
<head>
<title>Lets upload Photos</title>
</head>
<body>
<form enctype='multipart/form-data' action='upload.php' method='post' name='upload_form'>
<input type="hidden" name="MAX_FILE_SIZE" value="10000" />

<table width='90%' border='0' align='center' style='width: 90%;'>

<!-Insert the photo fields here -->
$photo_upload_fields

<tr>
<td>
        <input type='submit' name='submit' value='Add Photos' />
</td>
</tr>
</table>
</form>
</body>
</html>
__HTML_END;
?>

 

here is the upload.php

<?php
session_start();
// initialization
$result_final = "";
$counter = 0;
$cut_name = $_SESSION['tempdir'];
#$images_dir = $_SERVER['DOCUMENT_ROOT'].'/mygallery/photos/';
$images_dir = 'http://' . $_SERVER['HTTP_HOST'] . '/model/$cut_name';

// List of our known photo types
$known_photo_types = array(
					'image/pjpeg' => 'jpg',
					'image/jpeg' => 'jpg',
					'image/gif' => 'gif',
					'image/bmp' => 'bmp',
					'image/x-png' => 'png'
				);

// GD Function List
$gd_function_suffix = array(
					'image/pjpeg' => 'JPEG',
					'image/jpeg' => 'JPEG',
					'image/gif' => 'GIF',
					'image/bmp' => 'WBMP',
					'image/x-png' => 'PNG'
				);

// Fetch the photo array sent by preupload.php
$photos_uploaded = $_FILES['photo_filename'];

while($counter < count($photos_uploaded)) {
	if($photos_uploaded['size'][$counter] > 0)
	{
			$filename = $photos_uploaded['name'][$counter];
			$tmpname = $photos_uploaded['tmp_name'][$counter];
			$filesize = $photos_uploaded['size'][$counter];
			$filetype = $photos_uploaded['type'][$counter];

		//check the file if it is an image
		if(!array_key_exists($photos_uploaded['type'][$counter], $known_photo_types))
		{
			$result_final .= "<b>".($filename)."</b>";
			$result_final .= " is not a photo <br />";
		}
		else
		{

	chdir($_SERVER['DOCUMENT_ROOT'].'/');
	chdir('/model/$cut_name');

	//append file if it is not exist in /photos/ directory.
	if(!file_exists($filename)) {
		//checks if the file is
		if(is_uploaded_file($filename));
		{
			echo "<strong>";
			echo $filename, "<br>";
			echo "</strong>";
		}
	}

//check for duplicate, if no duplicate then insert and upload.
//if $filename equal to filename in the photo table then don't insert and upload.
//check the existence of $filename if exist then echo message.
	if(file_exists($filename)) {
		echo "<b>".($filename)."</b>", "  already exist! Please rename $filename ";
		echo "<br>";
	} else
	{
		//upload the file
		$uploaddir = $_SERVER['DOCUMENT_ROOT'].'/model/$cut_name';
		$uploadfile = $uploaddir . $filename;
		$dir_handler = $images_dir . $filename;

		if (move_uploaded_file($tmpname, $uploadfile)) {
			echo "Upload successful! <br>";
			echo "<img src=$dir_handler />";
			echo "<br>";
		} else {
			print "Failed to upload! <br>";
		}

			}
		}
echo $result_final;
	}
$counter++;
}
?>

 

 

Thank you very much in advance.

Link to comment
https://forums.phpfreaks.com/topic/48804-files-is-not-uploaded/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.