Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Hi there,

I have been trying to get a file upload script to work. I think the problem is with the file path of the destination. If this script is on the web server, and there is a folder called uploads, is that enough for the file path? Code follows:

<?php

if ((($_FILES["file"]["type"] == "image/gif")

|| ($_FILES["file"]["type"] == "image/jpeg")

|| ($_FILES["file"]["type"] == "image/pjpeg"))

&& ($_FILES["file"]["size"] < 20000))

{

if ($_FILES["file"]["error"] > 0)

{

echo "Return Code: " . $_FILES["file"]["error"] . "

";

}

else

{

echo "Upload: " . $_FILES["file"]["name"] . "

";

echo "Type: " . $_FILES["file"]["type"] . "

";

echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb

";

echo "Temp file: " . $_FILES["file"]["tmp_name"] . "

";

if (file_exists("/uploads/" . $_FILES["file"]["name"]))

{

echo $_FILES["file"]["name"] . " already exists. ";

}

else

{

move_uploaded_file($_FILES["file"]["tmp_name"],

"uploads/" . $_FILES["file"]["name"]);

echo "Stored in: " . "uploads/" . $_FILES["file"]["name"];

}

}

}

else

{

echo "Invalid file";

}

?>

Any advice gratefully received.

It should actually work fine though your if file exists check is off - you shouldn't be inserting a backslash in front of your file path if the upload folder resides in the same directory as your script... Anyway, just give this a shot, and if it doesn't work shoot back.

Another likely issue is that you don't have write access to the folder. If you're on linux or mac, give the webserver write rights.... if you're not sure, just change the permissions to 777 temporarily and cut them back gradually if it works. If you're on windows, then the IUSR account will need to have write rights...


<?php

if ((($_FILES["file"]["type"] == "image/gif") || ($_FILES["file"]["type"] == "image/jpeg") || ($_FILES["file"]["type"] == "image/pjpeg")) && ($_FILES["file"]["size"] < 20000))

{

	if ($_FILES["file"]["error"] > 0)

	{

		echo "Return Code: " . $_FILES["file"]["error"] . "

";

	}

	else

	{

		echo "Upload: " . $_FILES["file"]["name"] . "

";

		echo "Type: " . $_FILES["file"]["type"] . "

";

		echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb

";

		echo "Temp file: " . $_FILES["file"]["tmp_name"] . "

";

		if (file_exists(dirname(__FILE__)."/uploads/" . $_FILES["file"]["name"]))

		{

			echo $_FILES["file"]["name"] . " already exists. ";

		}

		else

		{

			move_uploaded_file($_FILES["file"]["tmp_name"],

			dirname(__FILE__)."/uploads/" . $_FILES["file"]["name"]);

			echo "Stored in: " . "uploads/" . $_FILES["file"]["name"];

		}

	}

	}

else

{

	echo "Invalid file";

}

?>

Cheers.

Edited by Guest

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.