PDA

View Full Version : Problem


panoramical
02-27-2005, 11:54 AM
For some reason, in my upload script, some files don't work, whereas others do. Is it perhaps to do with php.ini, and if it is, how can I modify it?


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<style type="text/css">
input.form
{
background-color: #B6D172;
font-family: Arial;
vertical-align: bottom
}

input.form:hover
{
background-color: #50563F;
font-family: Arial;
}
</style>

</head>
<body style="background-color: #999; font-family: Arial; font-size: 10px">
<img src="logo.jpg"
style="border: 1px solid #000"><p>


<form enctype="multipart/form-data" action="" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="30000" />
Send this file: <input name="userfile" type="file" class="form"/><br>
Desired Width: <input name="width" type="text" class="form"/><br>(height
will automatically scale)<br>
<input type="submit" value="Send File" class="form" />
</form>


<?php
$uploaddir = '/home/mariokartruk/public_html/uploads/';
$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);
$name = basename($_FILES['userfile']['name']);
$width3 = $_POST['width'];
$px = px;
$width = $width3 . $px;
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
echo "Here is your image: <br/><img src=\"/uploads/$name\"><br/>";
echo '<br>Here is the result of your code in eBay:<br>';
echo "<a href=\"http://www.mariokartresource.co.uk/uploads/$name\">
<img src=\"http://www.mariokartresource.co.uk/uploads/$name\"
alt=\"no\" style=\"width: $width; border: 1px solid #000\"/></a>";
echo '<br>Copy this code out into eBay where you want the image link:<br><xmp>';
echo "<a href=\"http://www.mariokartresource.co.uk/uploads/$name\">
<img src=\"http://www.mariokartresource.co.uk/uploads/$name\"
alt=\"no\" style=\"width: $width; border: 1px solid #000\"/></a>";
echo '</xmp>';
}
elseif ($name=="") {
echo 'Please enter the correct filename';
}
else {
echo 'Failed';
}
?>




</body>
</html>




http://www.mariokartresource.co.uk/upload.php
Thanks

darksidepuffin
02-27-2005, 12:56 PM
$_FILES["name"]["error"]

http://ca3.php.net/manual/en/features.file-upload.errors.php

Read.

And you've been here long enough to know cross posting is against the rules.

scoutt
03-01-2005, 08:17 PM
$px = px;

that is invalid, should be like this

$px = "px";

darksidepuffin
03-01-2005, 11:06 PM
Originally posted by scoutt
$px = px;

that is invalid, should be like this

$px = "px";

Agreed.

It's invalid,yeah...but won't it give him the "undefined constant PX,assuming 'PX' in ...." ...or does that only work if the constant-like name is uppercase?tho I know constants will error about a lowercase constant..but they won't choke...they'll assume uppercase.

scoutt
03-02-2005, 07:50 AM
I wasn't worried about undefined constant. and that is defining the contstant so no it won't. I would think it would give a parse error.

darksidepuffin
03-02-2005, 08:27 AM
Originally posted by scoutt
I wasn't worried about undefined constant. and that is defining the contstant so no it won't. I would think it would give a parse error.

Nope...

The code:


<?
error_reporting(E_ALL);
$px = px;
echo $px;
?>


The output:



Notice: Use of undefined constant px - assumed 'px' in /home/cubedpuf/public_html/test_const.php on line 3
px

scoutt
03-02-2005, 05:12 PM
ok, now quote the px, what do you get?

darksidepuffin
03-02-2005, 05:56 PM
Originally posted by scoutt
ok, now quote the px, what do you get?


Obviously I'd get px with no notice.But my point is..its a notice,Brian...not an error...it isn't gonna kill you ^_~

scoutt
03-02-2005, 07:48 PM
and that is my point, you code bad you get the "warning" I know it is not an error. I thought it should be at least have a parse error. you have to quote strings, no way around it.

darksidepuffin
03-02-2005, 08:08 PM
Originally posted by scoutt
and that is my point, you code bad you get the "warning" I know it is not an error. I thought it should be at least have a parse error. you have to quote strings, no way around it.

Yeah..I agree it's a bad way to do it,Brian.I'm simply pointing out that valid constant names won't choke php as strings without quotes.

scoutt
03-02-2005, 08:20 PM
I see that. actually it is choking but in a nice way.

if you switch those around you actually get the real warning.

maybe doing it the right way all these years makes me think it will error out seeing it like that

<?
error_reporting(E_ALL);
echo $px;
$px = px;
?>

Notice: Undefined variable: px in PHPDocument1 on line 3

Notice: Use of undefined constant px - assumed 'px' in PHPDocument1 on line 4

darksidepuffin
03-02-2005, 08:31 PM
Originally posted by scoutt
I see that. actually it is choking but in a nice way.

if you switch those around you actually get the real warning.

maybe doing it the right way all these years makes me think it will error out seeing it like that


No worries fur'gur...it's all good ^_____^