Jump to content

picture upload error - please help!


CageyJ0nnY

Recommended Posts

i have made a html form to upload a picture to webspce, it links to a php page that does the uploading and gives a message depending on if the image was successfully uploaded or not. I keep getting the error message and i cant figure out why. please help. here is the form:

 

<?php

$conn = mysql_connect('jjennings3db.bimserver2.com', 'jjennings3db', 'bullet8');

mysql_select_db('jjennings3db', $conn);

?>

 

<html>

<head>

<title>Picture Upload</title>

</head>

<body>

<form enctype="multipart/form-data" action="http://jjennings3.bimserver2.com/upload2.php" method="POST">

<p><input type="hidden" name="MAX_FILE_SIZE" value="100000">

Send this file: <input name="filename" type="file"></p>

<p>Name for uploaded file: <input name="filename" type="text" id="filename" value="picture.jpg"></p>

<p><input type="submit" value="Send File"></p>

</form>

<p><a href = "http://jjennings3.bimserver2.com/home-ltd.php"></p>

<li>Back</li>

</a>

</body>

</html>

 

and here is the php page:

 

<?php

$conn = mysql_connect('jjennings3db.bimserver2.com', 'jjennings3db', 'bullet4243');

mysql_select_db('jjennings3db', $conn);

 

$filename = ('$_POST[filename]');

$uploaddir = '/home/jjennings3/jjennings3.bimserver2.com/';

$uploadfile = $uploaddir . $filename;

if (move_uploaded_file($_FILES['image']['tmp_name'], $uploadfile)) {

echo "File is valid, and was successfully uploaded.<br>";

echo "Its name is <a href=$filename>$filename</a>";

} else {

echo "There was an error.";

}

?>

 

<html>

  <head>

<title>Imperial to Metric</title>

</head>

<body>

<p><a href = "http://jjennings3.bimserver2.com/upload.php"></p>

<li>Back</li>

</a>

</body>

</html>

 

any help would be apprieciated

 

Jonny

Link to comment
https://forums.phpfreaks.com/topic/202391-picture-upload-error-please-help/
Share on other sites

try this

<form enctype="multipart/form-data" action="upload_file.php" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="100000" />
Choose a file to upload: <input name="uploaded" type="file" /><br />
<input type="submit" name="Submit" value="Upload File" />
</form>
<?php 
if(isset($_POST['Submit']))
{
    

ini_set("display_errors",1);
error_reporting(E_ALL);
$target = "upload/"; 
$target = $target . basename( $_FILES['uploaded']['name']) ; 
$uploaded_type=strtolower(substr($_FILES['uploaded']['name'],strrpos($_FILES['uploaded']['name'],'.')+1));
print_r($_FILES['uploaded']);
echo "<br>FileX ".$uploaded_type;

//This is our limit file type condition 
if (($uploaded_type=="gif")||($uploaded_type=="jpg")||($uploaded_type=="png")||($uploaded_type=="pdf")||($uploaded_type=="doc")) 
{ 

if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) 
{ 
echo "The file ". basename( $_FILES['uploaded']['name']). " has been uploaded"; 
} 
else 
{ 
echo "Sorry, there was a problem uploading your file."; 
} 

} 
else 
{ 
echo "These files cannot be uploaded<br>"; 
}
}
include $img . $filename . "." . $ext;
?>

I have tried the code above, but i am getting this error message? I dont have a clue what i am doing wrong (im new to this)?

 

Array ( [name] => img.jpg [type] => image/jpeg [tmp_name] => /tmp/php1X7FhM [error] => 0 => 2218 )

FileX jpg

Warning: move_uploaded_file(upload/img.jpg) [function.move-uploaded-file]: failed to open stream: No such file or directory in /home/jjennings3/jjennings3.bimserver2.com/upload2.php on line 18

 

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/php1X7FhM' to 'upload/img.jpg' in /home/jjennings3/jjennings3.bimserver2.com/upload2.php on line 18

Sorry, there was a problem uploading your file.

 

# Back

 

 

thanks

 

Jonny

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.