Jump to content

[SOLVED] image upload


chriscloyd

Recommended Posts

this is my script

 

<?php
session_start();
mysql_connect('localhost','******','******') or die('Could not connect to the server');
mysql_select_db('******') or die('Could not select database');
$uploaddir = 'images/users/';
$rand = rand(0,8790);
$uploadfile = $uploaddir . $_SESSION['username'] . $rand . basename($_FILES['userfile']['name']);
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
$update = mysql_query("UPDATE users SET user_image = '".$uploadfile."' WHERE username = '".$_SESSION['username']."'");
if ($update) {
    	header ("Location: ../index.php?page=actcreated");
}
} else {
    echo "Possible file upload attack!\n";
}
?> 

 

 

this is the result when i run the script

 

Warning: move_uploaded_file(images/users/haqshot2426haq.jpg) [function.move-uploaded-file]: failed to open stream: No such file or directory in /home/ccloyd/public_html/process/uploadfile.php on line 8

 

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpER2301' to 'images/users/haqshot2426haq.jpg' in /home/ccloyd/public_html/process/uploadfile.php on line 8

Possible file upload attack! Here is some more debugging info:Array ( [userfile] => Array ( [name] => haq.jpg [type] => image/jpeg [tmp_name] => /tmp/phpER2301 [error] => 0 => 29004 ) )

Link to comment
https://forums.phpfreaks.com/topic/63284-solved-image-upload/#findComment-315415
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.