A
Anonymous
Guest
*Disclaimer* I'm a newbie
After trying many different scipts to upload files I finally got one to work...almost.
The script renames the file to something like this 'phpcCsWrf.jpg' and stores it in the directory you choose and stores the filename in the database. I set up the permissions to 777 in the image directory and the image gets uploaded to it with no problem. The problem occurs when I try to access the newly uploaded picture. I get an access denied when trying to download the picture to my local or even trying to view it through my file manager. The newly uploaded pictures are the only files in the folder that yeild this error message. I hope that's enough info for someone to give me an idea of whats going on but if not here is the script i am using:
<body>
<?php
if ($FileToUpload_type == 'image/gif') {
$type = '.gif';
}
if ($FileToUpload_type == 'image/pjpeg') {
$type = '.jpg';
}
if ($FileToUpload_type == 'image/x-png') {
$type = '.jpg';
}
$newfile = substr($FileToUpload, -9);
if($FileToUpload_name = '') {
print("No file was selected!");
}
elseif($FileToUpload_size > $MaxFileSize) {
print("The file to upload is too big");
}
else {
$global_db = mysql_connect('localhost', 'newbie_update', 'boot');
mysql_select_db('newbie_update', $global_db) or die("Connection error");
$query = "INSERT INTO setup (photo) VALUES ('$newfile$type')";
$result = mysql_query($query) or die("ERROR");
move_uploaded_file($FileToUpload, "/home/newbie/public_html/images/$newfile$type");
}
?>
</body>
_____________________________________________________
@Html page for user upload@
<body>
<form name=form1 action=upload_file.php method=post enctype=multipart/form-data>
<input type=file name=FileToUpload>
<input type=hidden name=MaxFileSize value=64000>
<input type="submit" name="Submit" value="Submit">
</form>
</body>
Any insight would be appreciated.
After trying many different scipts to upload files I finally got one to work...almost.
The script renames the file to something like this 'phpcCsWrf.jpg' and stores it in the directory you choose and stores the filename in the database. I set up the permissions to 777 in the image directory and the image gets uploaded to it with no problem. The problem occurs when I try to access the newly uploaded picture. I get an access denied when trying to download the picture to my local or even trying to view it through my file manager. The newly uploaded pictures are the only files in the folder that yeild this error message. I hope that's enough info for someone to give me an idea of whats going on but if not here is the script i am using:
<body>
<?php
if ($FileToUpload_type == 'image/gif') {
$type = '.gif';
}
if ($FileToUpload_type == 'image/pjpeg') {
$type = '.jpg';
}
if ($FileToUpload_type == 'image/x-png') {
$type = '.jpg';
}
$newfile = substr($FileToUpload, -9);
if($FileToUpload_name = '') {
print("No file was selected!");
}
elseif($FileToUpload_size > $MaxFileSize) {
print("The file to upload is too big");
}
else {
$global_db = mysql_connect('localhost', 'newbie_update', 'boot');
mysql_select_db('newbie_update', $global_db) or die("Connection error");
$query = "INSERT INTO setup (photo) VALUES ('$newfile$type')";
$result = mysql_query($query) or die("ERROR");
move_uploaded_file($FileToUpload, "/home/newbie/public_html/images/$newfile$type");
}
?>
</body>
_____________________________________________________
@Html page for user upload@
<body>
<form name=form1 action=upload_file.php method=post enctype=multipart/form-data>
<input type=file name=FileToUpload>
<input type=hidden name=MaxFileSize value=64000>
<input type="submit" name="Submit" value="Submit">
</form>
</body>
Any insight would be appreciated.