Quantcast
Channel: PHP Freaks: PHP Help
Viewing all articles
Browse latest Browse all 13200

Basic php photo post and upload

$
0
0

Hey Guys,

 

Just stuck on this php form to upload.  I am trying to post a photo to the upload script.  For some reason it seems that only the photo's filename is being passed on from the form to the upload script, but not the actual photo.

 

Any help is much appreciated.

 

My code:

 

Form page:

<?php 

include("image_upload_script.php");




?>
        
<form enctype="multipart/form-data" class="clearfix" action="" method="post">
						<?php
                            
                            if($_SESSION['msg']['login-err'])
                            {
                                echo '<div class="err">'.$_SESSION['msg']['login-err'].'</div>';
                                unset($_SESSION['msg']['login-err']);
                            }
                        ?>
Choose your file here:
<input name="uploaded_file" type="file"/><br /><br />
<input type="submit" name="submit" value="Upload It" class="" />
</form>

Upload script:

<?php
session_start();
$pid ='1000';
if($_POST['submit']=='Upload It')
{

// Access the $_FILES global variable for this specific file being uploaded
// and create local PHP variables from the $_FILES array of information
$fileName = $_POST["uploaded_file"]["name"]; // The file name
$fileTmpLoc = $_POST["uploaded_file"]["tmp_name"]; // File in the PHP tmp folder
$fileType = $_POST["uploaded_file"]["type"]; // The type of file it is
$fileSize = $_POST["uploaded_file"]["size"]; // File size in bytes
$fileErrorMsg = $_POST["uploaded_file"]["error"]; // 0 for false... and 1 for true
$kaboom = explode(".", $fileName); // Split file name into an array using the dot
$fileExt = end($kaboom); // Now target the last array element to get the file extension
$fileName = $pid.".".$fileExt; //rename

// Image handling after this, cut out for simplicity --------------------------------------------------

}


?>

Viewing all articles
Browse latest Browse all 13200