getartzy
08-06-2007, 02:36 PM
I have been trying for days to get my php scripts to upload a file. The script worked before on my machine but not on host monster. I changed the permissions of the folder to allow writing by every one,I changed the php.ini max size(as per the knowledge db entry.) to be greater than the filesize I am uploading, and I have searched on here(might have missed it though.) I have also been playing with my code to see If I did any thing wrong. So far I have no answers except.
Warning: move_uploaded_file(/artistsfiles/979293716_l.jpg) [function.move-uploaded-file]: failed to open stream: No such file or directory in /home/getartzy/public_html/upload.php on line 12
Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpz1K3tn' to '/artistsfiles/979293716_l.jpg' in /home/getartzy/public_html/upload.php on line 12
Sorry thier was an error uploading this file! This could be due to a large file size. The current limit is 1MB
Array
(
[userfile] => Array
(
[name] => 979293716_l.jpg
[type] => image/jpeg
[tmp_name] => /tmp/phpz1K3tn
[error] => 0
[size] => 23216
)
)
Which is not a vary good answer.
I wrote the message "Sorry their was an error uploading this file! This could be due to a large file size. The current limit is 1MB" in my script to show the user a failer. But the first two messages are confusing to me and I don't don't know why I am getting them.
<?php
INCLUDE 'dbs.php';
INCLUDE 'sitelayout.php';
connect();
$frrt = "UPDATE `artist profiles` SET `port` = '1' WHERE `uid` = '".$_COOKIE['igg']."' ";
$result = mysql_query($frrt);
$frrt = "UPDATE `accounts` SET `port` = '1' WHERE `ID` = '".$_COOKIE['igg']."' ";
$result = mysql_query($frrt);
$uploaddir = '/artistsfiles/';
$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);
echo '<pre>';
$hy = move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile);
if ($hy) {
$frrt = "SELECT `id` FROM `artist profiles` WHERE `uid` = '".$_COOKIE['igg']."' LIMIT 0, 30 ";
$result = mysql_query($frrt);
while ($tt = mysql_fetch_array($result)) {
$frrt = "INSERT INTO `portfolio` (`uid`,`filename`, `desc`, `capt`,`proid`) VALUES ('".$_COOKIE['igg']."','".$_FILES['userfile']['name']."','".$_REQUEST['descript']."','".$_REQUEST['caption']."','".$tt{'id'}."')";
$result = mysql_query($frrt);
echo "<meta http-equiv=\"Refresh\" content=\"0; URL= Artisthome.php?igg=".$_REQUEST['igg']."\">";
}
} else {
echo "Sorry thier was an error uploading this file! This could be due to a large file size. The current limit is 1MB\n";
}
print_r($_FILES);
?>
What am I doing wrong?
Warning: move_uploaded_file(/artistsfiles/979293716_l.jpg) [function.move-uploaded-file]: failed to open stream: No such file or directory in /home/getartzy/public_html/upload.php on line 12
Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpz1K3tn' to '/artistsfiles/979293716_l.jpg' in /home/getartzy/public_html/upload.php on line 12
Sorry thier was an error uploading this file! This could be due to a large file size. The current limit is 1MB
Array
(
[userfile] => Array
(
[name] => 979293716_l.jpg
[type] => image/jpeg
[tmp_name] => /tmp/phpz1K3tn
[error] => 0
[size] => 23216
)
)
Which is not a vary good answer.
I wrote the message "Sorry their was an error uploading this file! This could be due to a large file size. The current limit is 1MB" in my script to show the user a failer. But the first two messages are confusing to me and I don't don't know why I am getting them.
<?php
INCLUDE 'dbs.php';
INCLUDE 'sitelayout.php';
connect();
$frrt = "UPDATE `artist profiles` SET `port` = '1' WHERE `uid` = '".$_COOKIE['igg']."' ";
$result = mysql_query($frrt);
$frrt = "UPDATE `accounts` SET `port` = '1' WHERE `ID` = '".$_COOKIE['igg']."' ";
$result = mysql_query($frrt);
$uploaddir = '/artistsfiles/';
$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);
echo '<pre>';
$hy = move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile);
if ($hy) {
$frrt = "SELECT `id` FROM `artist profiles` WHERE `uid` = '".$_COOKIE['igg']."' LIMIT 0, 30 ";
$result = mysql_query($frrt);
while ($tt = mysql_fetch_array($result)) {
$frrt = "INSERT INTO `portfolio` (`uid`,`filename`, `desc`, `capt`,`proid`) VALUES ('".$_COOKIE['igg']."','".$_FILES['userfile']['name']."','".$_REQUEST['descript']."','".$_REQUEST['caption']."','".$tt{'id'}."')";
$result = mysql_query($frrt);
echo "<meta http-equiv=\"Refresh\" content=\"0; URL= Artisthome.php?igg=".$_REQUEST['igg']."\">";
}
} else {
echo "Sorry thier was an error uploading this file! This could be due to a large file size. The current limit is 1MB\n";
}
print_r($_FILES);
?>
What am I doing wrong?