Hi
I have had a client asking me to look at the image upload section of the site i have built for them:
Here is the upload form code:
<form enctype="multipart/form-data" action="processupload.php" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="100000000000" />
<center>Choose photo to upload: <input name="uploadedfile" type="file" /><br><br>
<input type="submit" value="Go to next step >>" /><center>
</form>
Here is the processing of the upload:
<?php
session_start();
// Where the file is going to be placed
$target_path = "images/";
/* Add the original filename to our target path.
Result is "uploads/filename.extension" */
$target_path = $target_path.basename($_FILES['uploadedfile']['name']);
$target_path = "images/";
$target_path = $target_path.basename($_FILES['uploadedfile']['name']);
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
$message ="The file ".basename($_FILES['uploadedfile']['name'])."has been uploaded";
} else{
echo "There was an error uploading the file, please try again!";
}
header("Location: addcontact.php?file=$target_path");
?>
Here is the code to update the file once uploaded:
<form enctype="multipart/form-data" action="changephotouploadprocess.php" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="100000000000" />
<center>Choose photo to upload: <input name="uploadedfile" type="file" /><br><br>
<input type="text" name="id" value="<?php echo $_SESSION['id']; ?>">
<input type="text" name="oldfilename" value="<?php echo $_SESSION['oldfilename']; ?>">
<?php
session_start();
$id = $_GET['id'];
$oldfilename = $_GET['oldfilename'];
// Where the file is going to be placed
$target_path = "images/";
/* Add the original filename to our target path.
Result is "uploads/filename.extension" */
$target_path = $target_path.basename($_FILES['uploadedfile']['name']);
$target_path = "images/";
$target_path = $target_path.basename($_FILES['uploadedfile']['name']);
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
$message ="The file ".basename($_FILES['uploadedfile']['name'])."has been uploaded";
} else{
echo "There was an error uploading the file, please try again!";
}
header("Location: confirmupdate.php?file=$target_path");
?>
I am having the problem where some image files are not uploading or updating.
I am not sure what is going on and I am very desperate to fix the issue.
Please can someone help?