Jump to content

Archived

This topic is now archived and is closed to further replies.

r-it

File uploads

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.

Share this post


Link to post
Share on other sites
numerous questions, BUT to help solve we need to see some code.

(as to the sessions problem - have you started sessions at the top of every page?)

Lite

Share this post


Link to post
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";
}

}

Share this post


Link to post
Share on other sites

×

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.