Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.