PHP Script File Upload

I have a website which i created, and part of it is a PHP form which allows users to upload images. This has always worked, but stopped working today, with no visible error. Has anything changed on the hosting side? It isn’t a filesize issue since the image is 300kb in size.

Thank you

I’ve checked your uploader, and it seems there aren’t any issues. Could you be more specific about the question? And try turning on PHP debugger from Cpanle.

Try uploading a new recipe with an image using the above link.
It should add the picture with the recipe.

it just asks for a login

Could you please share your Upload logic?

if(!empty($_FILES["imageupload"]["tmp_name"]))
	{
		$targetDir = "../images/";
		$fileName = $_POST['ID'] . ".jpg";
		$targetFilePath = $targetDir . $fileName;
		$fileType = pathinfo($targetFilePath,PATHINFO_EXTENSION);

		move_uploaded_file($_FILES["imageupload"]["tmp_name"], $targetFilePath);
	}
	else
		$fileName = NULL;

Keep in mind the code works properly on localhost

It generally seems okay, but try removing two dots from tragetdir

if(!empty($_FILES["imageupload"]["tmp_name"]))
	{
		$targetDir = "/images/";
		$fileName = $_POST['ID'] . ".jpg";
		$targetFilePath = $targetDir . $fileName;
		$fileType = pathinfo($targetFilePath,PATHINFO_EXTENSION);

		move_uploaded_file($_FILES["imageupload"]["tmp_name"], $targetFilePath);
	}
	else
		$fileName = NULL;```

you can sign up for an account to test if you’d like

No, that didn’t work. The script that processes the upload is in a subfolder /api/

Check your images folder; I uploaded a smiley png.

Nope, the image was not saved, nor was the image filename written to my database.

Okay, i tested this with my website and it worked for me, try this

$targetDir = __DIR__ . "/../images/";
1 Like

That didnt work.

!empty($_FILES[“imageupload”][“tmp_name”]) is resolveing to true, so the code to rename the file never runs.

Provide me the full code, without it i can’t know for sure what’s the issue.

I’ve done some debugging, and this is the error on the file uploaded.
UPLOAD_ERR_NO_TMP_DIR, value 6, means that no temporary directory is specified in the
php.ini.

Below code works for me,

($_FILES["files"]["tmp_name"])

And I can’t be of any help unless you provide your full uploading code.

this could be related to the tmp folder issues all wordpress hostings on IF are currently having.

[Code Removed]

Can you share the thread on this please? Must be the same thing.
Something seems to be wrong with the php.ini config

Hey, it’s not an error from your end; it’s a server issue. I checked with my website, and my images are not uploading either.

1 Like