PHP Image Upload Script

Pozdrav,
Pokusavajuci napraviti neku simple scriptu za upload slika dosao sam do problema :slight_smile:
Ovako, kada uploadam sliku sve je ok, ali ostane mi npr text “Vasa slika je uploadana” u tom php fajlu kad god ga otvorim, evo i source(nemojte ga ukrasti :slight_smile: ) :

Hvala.

[php]$upload = move_uploaded_file($file_stored, $upload_path . $file_name_new);

if($upload) {
echo “Image was successfully uploaded.”;
echo “
”;
echo “
”;

#header(‘refresh: 5; url=’.$upload_path . $file_name_new); // Remove # if you want script redirects to image.

echo “BBCode for Forums:
”%20.%20$script_path%20.%20$upload_path%20.%20$file_name_new%20.%20"
";
echo “
”;
echo "Direct link: " . $script_path . $upload_path . $file_name_new;

}else {
echo “some error”;
}[/code]

ovako nesto?

[php]
if (($file_type == “image/jpeg”) || ($file_type == “image/gif”) || ($file_type == “image/png”) || ($file_type == “image/bmp”)) {

$upload = move_uploaded_file($file_stored, $upload_path . $file_name_new);

echo “Image was successfully uploaded.”;
echo “
”;
echo “
”;

header(‘refresh: 5; url=’.$upload_path . $file_name_new); // Remove # if you want script redirects to image.

echo “BBCode for Forums:
”%20.%20$script_path%20.%20$upload_path%20.%20$file_name_new%20.%20"
";
echo “
”;
echo "Direct link: " . $script_path . $upload_path . $file_name_new;

} else {

echo “You can upload only images with JPG, GIF, PNG, BMP extension!”;

}
[/php]
Napisao sam tako,ali opet ostaje text u upload.php :confused:

[quote=“Nedim”][php]
if (($file_type == “image/jpeg”) || ($file_type == “image/gif”) || ($file_type == “image/png”) || ($file_type == “image/bmp”)) {

$upload = move_uploaded_file($file_stored, $upload_path . $file_name_new);

echo “Image was successfully uploaded.”;
echo “
”;
echo “
”;

header(‘refresh: 5; url=’.$upload_path . $file_name_new); // Remove # if you want script redirects to image.

echo “BBCode for Forums:
”%20.%20$script_path%20.%20$upload_path%20.%20$file_name_new%20.%20"
";
echo “
”;
echo "Direct link: " . $script_path . $upload_path . $file_name_new;

} else {

echo “You can upload only images with JPG, GIF, PNG, BMP extension!”;

}
[/php]
Napisao sam tako,ali opet ostaje text u upload.php :/[/quote]

pa s ovim tvojim kodom, ti si samo definirao varijablu, sad ju moras inicijalizirati :smiley:

i stavis if($varijabla_za_upload) { // kod dalje }else { }

Aha,znam,nego sam mahinalno kopirao kod,moja greska.
Ali opet ostaje text "You can upload only images with JPG, GIF, PNG, BMP extension! " u upload.php :confused: ?
[php]if (($file_type == “image/jpeg”) || ($file_type == “image/gif”) || ($file_type == “image/png”) || ($file_type == “image/bmp”)) {

$upload = move_uploaded_file($file_stored, $upload_path . $file_name_new);
}

if($upload) {

echo “Image was successfully uploaded.”;
echo “
”;
echo “
”;

header(‘refresh: 5; url=’.$upload_path . $file_name_new); // Remove # if you want script redirects to image.

echo “BBCode for Forums:
”%20.%20$script_path%20.%20$upload_path%20.%20$file_name_new%20.%20"
";
echo “
”;
echo "Direct link: " . $script_path . $upload_path . $file_name_new;
die;

} else {

echo “You can upload only images with JPG, GIF, PNG, BMP extension!”;

}[/php]


Izbriši taj red pa neće pisat ta rečenica!

Izbriši taj red pa neće pisat ta rečenica!

Oh kako si ti samo pametan :open_mouth:
Moze katanac rijesio sam.


Copyright © 2020 WM Forum - AboutContact - Sponsored by: Mydataknox & Webmaster.Ninja