Jump to content

File uploads


r-it

Recommended Posts

Can anyone please help me. I have this project i'm doing in php, where a user registers and an email is sent 2 them yadiyadihah, thats all easy, but the 1st problem is when the user goes to the home page and when they click on login, it goes to the login page(i got the session idea from here), and then it displays the PHPSESSID in the url the 1st time but this goes away after u go to other pages and come back. The second this is the file upload, when i was testing locally, everything was fine, but then when i sent it to our server, things started falling apart, we first had to change all of our scripts 2 have a php5 extension, bt enough abt that, the problem is that i hav to upload certain documents from the user, and i'm using leechftp, and i have changed the directory attributes for the uploads directory to be 777 ie RWE so that things can be uploaded, but thats not working, coz the script that handles that just becomes blank, i don't know y. Do i probably have to put the full path as in: $directory = "http://www............../uploads/" or something coz i tried that and it didn't work as well. oh and another thing is md flippen 5, yes md5, is it not supposed to hash text the same way, coz i hashed the password and the problem is that it gives a different hash for the same password when i'm loggin in or something; basically, the hashed password in the database is different to the one i enter when logging in.
any wise help would be highly appreciated.
Link to comment
Share on other sites

<?php
session_start();
include 'conn.php'



$num = 1;
$user = $_SESSION['username'];
$name = $_SESSION['username'] . $num;
$tempname = $_FILES['fileupload']['tmp_name'];
$dir = "../uploads/";
$filename = $name . substr($_FILES['fileupload']['name'], -4);

$res = move_uploaded_file($_FILES['fileupload']['tmp_name'], $dir.$name) ; //or die ("couldnt copy file....")

if($res)
{

$sql = "SELECT * FROM users WHERE login = '".$user."'";
$result = mysql_query($sql) or die(mysql_error());
while($newArray = mysql_fetch_array($result))
{
$id = $newArray['id'];
}
$link = $url.$dir.$name;
$link = addslashes($link);

$insql = "INSERT INTO dataTable values ('".$id."', '".$link."')";
if(mysql_query($insql))
{
echo "File uploaded Successfully<br /> \n";
echo "File name is $name <br /> \n";
}
else
{
echo "something went wrong";
}

}
Link to comment
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.